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-intl/next

v0.11.1

Published

Next.js App Router integration for better-intl

Readme

@better-intl/next

Next.js App Router integration for better-intl.

Install

npm install @better-intl/next @better-intl/react @better-intl/core @better-intl/compiler

Quick Start

1. Configure

// better-intl.config.json
{
  "defaultLocale": "en",
  "locales": ["en", "pt-BR", "es"],
  "catalogs": "./locales/{locale}.json",
  "include": ["app/**/*.tsx"]
}

2. Plugin (next.config.js)

import { withBetterIntl } from "@better-intl/next/plugin";

export default withBetterIntl({
  locales: ["en", "pt-BR", "es"],
  defaultLocale: "en",
})({
  // your next config
});

3. Middleware

// middleware.ts
import { createIntlMiddleware } from "@better-intl/next/middleware";

export default createIntlMiddleware({
  locales: ["en", "pt-BR", "es"],
  defaultLocale: "en",
});

export const config = { matcher: ["/((?!api|_next|.*\\..*).*)"] };

4. Layout

// app/[locale]/layout.tsx
import { NextIntlClientProvider } from "@better-intl/next/client";

export default async function Layout({
  children,
  params,
}: {
  children: React.ReactNode;
  params: Promise<{ locale: string }>;
}) {
  const { locale } = await params;
  const messages = (await import(`../../locales/${locale}.json`)).default;

  return (
    <html lang={locale}>
      <body>
        <NextIntlClientProvider locale={locale} messages={messages}>
          {children}
        </NextIntlClientProvider>
      </body>
    </html>
  );
}

5. Write normal JSX

// app/[locale]/page.tsx
export default function Page() {
  return (
    <section>
      <h1>Hello world</h1>
      <p>The best SaaS platform</p>
      <button type="button">Get started</button>
    </section>
  );
}

That's it. No t() calls, no hooks, no imports. The Babel plugin transforms your JSX automatically at build time:

// What the compiler generates behind the scenes:
import { useTranslation } from "@better-intl/react";

export default function Page() {
  const { t: __t } = useTranslation();
  return (
    <section>
      <h1>{__t("0rr2b7c", undefined, "Hello world")}</h1>
      <p>{__t("1di71qw", undefined, "The best SaaS platform")}</p>
      <button type="button">{__t("1gvrrqk", undefined, "Get started")}</button>
    </section>
  );
}

Enable it via Babel:

// babel.config.js
module.exports = {
  plugins: [["@better-intl/compiler/babel", { mode: "auto" }]],
};

Or for zero-runtime (inlines translations at build time):

module.exports = {
  plugins: [
    ["@better-intl/compiler/babel", {
      locale: "pt-BR",
      messages: require("./locales/pt-BR.json"),
    }],
  ],
};

Server Components (RSC)

For React Server Components where hooks aren't available, use getTranslator:

// app/[locale]/page.tsx
import { getTranslator } from "@better-intl/next/server";

export default async function Page({
  params,
}: {
  params: Promise<{ locale: string }>;
}) {
  const { locale } = await params;
  const t = await getTranslator(locale, () =>
    import(`../../locales/${locale}.json`)
  );

  return <h1>{t("greeting")}</h1>;
}

Metadata

import { getMetadataTranslator } from "@better-intl/next/server";

export async function generateMetadata({
  params,
}: {
  params: Promise<{ locale: string }>;
}) {
  const { locale } = await params;
  const t = await getMetadataTranslator(locale, () =>
    import(`../../locales/${locale}.json`)
  );

  return { title: t("page.title") };
}

API

| Export | Entry point | Description | |--------|-------------|-------------| | NextIntlClientProvider | @better-intl/next/client | Client provider for layouts | | createIntlMiddleware(config) | @better-intl/next/middleware | Locale detection and routing | | getTranslator(locale, loader) | @better-intl/next/server | Server-side t() for RSC | | getMetadataTranslator(locale, loader) | @better-intl/next/server | For generateMetadata | | getMessages(loader) | @better-intl/next/server | Load messages for a locale | | withBetterIntl(config) | @better-intl/next/plugin | next.config.js plugin |

License

MIT