npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@better-translate/nextjs

v1.2.1

Published

Next.js integration package for Better Translate.

Readme

Next.js

Use @better-translate/nextjs when you want locale-prefixed URLs, server-side translations, and locale-aware navigation in App Router.

If you also need client-side hooks, add @better-translate/react on top of this setup.

1. Install the packages

npm install @better-translate/core @better-translate/nextjs

2. Create the translator

Create src/lib/i18n/config.ts:

import { configureTranslations } from "@better-translate/core";

const en = {
  home: {
    title: "Hello from Next.js",
  },
} as const;

const es = {
  home: {
    title: "Hola desde Next.js",
  },
} as const;

export const translator = await configureTranslations({
  availableLocales: ["en", "es"] as const,
  defaultLocale: "en",
  fallbackLocale: "en",
  messages: { en, es },
});

3. Add the routing file

Create src/lib/i18n/routing.ts:

import {
  defineRouting,
  SUPPORTED_NEXTJS_LOCALE_ROUTE_SYNTAXES,
} from "@better-translate/nextjs";

export const routing = defineRouting({
  defaultLocale: "en",
  locales: ["en", "es"] as const,
  routeTemplate: "/[lang]",
});

console.log(SUPPORTED_NEXTJS_LOCALE_ROUTE_SYNTAXES);

4. Add the request and server helpers

Better Translate restricts the locale param name to the shared supported list from core. Valid examples include [locale], [lang], [language], [intl], [i18n], [l10n], and [localization].

Create src/lib/i18n/request.ts:

import { getRequestConfig } from "@better-translate/nextjs/server";

import { translator } from "./config";

export const requestConfig = getRequestConfig(async () => ({
  translator,
}));

Create src/lib/i18n/server.ts:

import { createServerHelpers } from "@better-translate/nextjs/server";

import { requestConfig } from "./request";

export const { getTranslations } = createServerHelpers(requestConfig);

5. Add locale-aware navigation

Create src/lib/i18n/navigation.ts:

"use client";

import Link from "next/link";
import { useParams, usePathname, useRouter } from "next/navigation";

import { createNavigationFunctions } from "@better-translate/nextjs/navigation";

import { routing } from "./routing";

export const {
  Link: I18nLink,
  usePathname: useI18nPathname,
  useRouter: useI18nRouter,
} = createNavigationFunctions({
  Link,
  routing,
  useParams,
  usePathname,
  useRouter,
});

6. Add the proxy

Create src/proxy.ts:

import { createProxy, getProxyMatcher } from "@better-translate/nextjs/proxy";

import { routing } from "./lib/i18n/routing";

export const proxy = createProxy(routing);

export const config = {
  matcher: getProxyMatcher(routing),
};

7. Render a translated page

Create src/app/[lang]/page.tsx:

import { setRequestLocale } from "@better-translate/nextjs/server";

import { getTranslations } from "../../lib/i18n/server";

export default async function HomePage({
  params,
}: {
  params: Promise<{ lang: string }>;
}) {
  const { lang } = await params;

  setRequestLocale(lang);

  const t = await getTranslations();

  return <h1>{t("home.title")}</h1>;
}

8. Add links that keep the locale

Create src/components/language-links.tsx:

"use client";

import { I18nLink } from "../lib/i18n/navigation";

export function LanguageLinks() {
  return (
    <nav>
      <I18nLink href="/" locale="en">
        English
      </I18nLink>
      {" | "}
      <I18nLink href="/" locale="es">
        Espanol
      </I18nLink>
    </nav>
  );
}

When to add the React adapter

Add @better-translate/react only when client components need useTranslations() or a provider.

Generate locale files automatically

Instead of writing every translation by hand, use the CLI to extract strings and generate locale files: CLI guide

Examples