next-tongue
v0.9.18
Published
Compiler-first, type-safe i18n for the Next.js 16 App Router
Maintainers
Readme
next-tongue
Compiler-first, type-safe i18n for the Next.js 16 App Router. Works with Turbopack, keeps the locale in route params, zero dependencies beyond next and react.
Beta 0.9 — public API is frozen. See API freeze.
Install
npm install next-tongue
npx tongue initRequires Next.js ≥ 16 (App Router) and React ≥ 19.
Quick start
// tongue.config.ts
import { defineConfig } from 'next-tongue/config';
export default defineConfig({
locales: ['en', 'de'],
defaultLocale: 'en',
messages: './messages/{locale}.json',
});// next.config.ts
import { withTongue } from 'next-tongue/next';
export default withTongue({ cacheComponents: true });// proxy.ts — locales + defaultLocale are required
import { createProxy } from 'next-tongue/proxy';
export const proxy = createProxy({
locales: ['en', 'de'],
defaultLocale: 'en',
prefix: 'as-needed',
});
export const config = { matcher: ['/((?!api|_next|.*\\..*).*)'] };// app/[locale]/page.tsx
import { getT } from 'next-tongue/server';
export default async function Page({
params,
}: {
params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
const t = await getT(locale, 'home');
return <h1>{t('title')}</h1>;
}Package exports
| Import | Use |
|---|---|
| next-tongue/config | defineConfig |
| next-tongue/next | withTongue |
| next-tongue/server | getT, getFormat, localeParams, … |
| next-tongue/client | TongueProvider, useT, … |
| next-tongue/proxy | createProxy |
| next-tongue/navigation | createNavigation |
| next-tongue/testing | test helpers |
CLI: tongue build | check | extract | init | export | import | report | translate | migrate
Docs
License
MIT © Louis Wright
