next-i18next
next-i18next brings i18next to Next.js: language in the address, Server and Client Components, and the translations handed from the server to the browser.
Set up next-i18next with your coding agent
Paste this prompt into Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI or any agent that can run terminal commands:
Localize this app with i18next.
Run `npx i18next-cli localize --print-agent-prompt` and follow
the steps it prints, in order, checking each one before the next.
Your agent wraps the texts in await getT() in Server Components and useT() in Client Components and writes the translation files; you review the diff, and the translation files stay in your repository unless you choose a translation management service.
⇒ What the prompt tells your agent
Everything that is not specific to Next.js is i18next and react-i18next: the t function, plurals, interpolation, namespaces and the translation files. It works with the App Router, the Pages Router, and apps that use both.
Where to start
- A new App Router app: App Router setup. Then choose how the language shows in the
address: in the path (
/de/about, the default), without a prefix for the default language, only in a cookie, or clean addresses that still prerender. - An app on the Pages Router: Pages Router setup.
- Both routers in one app: Mixed routers.
- Coming from v15: Migration from v15.
- Complete projects: the examples in the repository.
What there is
- App Router:
getT()in Server Components,useT()in Client Components,createProxy()for language detection and routing. - Language in the path or not: locale-in-path (
/en/about), no-locale-path (the language in a cookie) and internal locale mode (clean addresses, static prerendering per language). - Mixed routers: the App Router and the Pages Router in one app, scoped with
basePath. - Any i18next backend:
i18next-http-backend,i18next-chained-backendand others, see Custom backends. - A proxy without Node.js modules, so it runs on the Edge runtime.
- The Pages Router API:
appWithTranslationandserverSideTranslations, imported fromnext-i18next/pagesandnext-i18next/pages/serverSideTranslations.