This is an example of how to use next-i18next v16 with Next.js and Locize to get translations up and running quickly and easily.
It demonstrates both the App Router and the Pages Router in a single project using the basePath option for mixed-router setups.
- next-i18next v16 blog post — full setup guide
- next-i18next README — API reference and examples
- next-i18next v16 examples — more example projects
- Server Components use
getT()fromnext-i18next/serverto load translations from the filesystem (bundled viaresourceLoader) - Client Components use
I18nProviderwithi18next-locize-backend+i18next-chained-backend+i18next-localstorage-backendfor live translation downloads with localStorage caching - Proxy (
proxy.js) handles language detection and routing, scoped to/app-router/*viabasePath
- Uses the familiar
appWithTranslation/serverSideTranslationsAPI vianext-i18next/pages - Client-side translation reloading via
i18next-locize-backendwith chained backend - Server-side translations bundled from
public/locales/(downloaded vialocize-cli)
Translations are managed in Locize and synced to the project:
- At build time:
npm run downloadLocalesdownloads translations from Locize topublic/locales/via locize-cli - At runtime (client):
i18next-locize-backendfetches fresh translations from the Locize CDN with localStorage caching (1 hour expiration)
This approach is ideal for serverless deployments — translations are bundled at build time, so no server-side HTTP requests are needed. The client can still get fresh translations from Locize.
npm install
npm run downloadLocales # download translations from Locize
npm run dev- Pages Router: http://localhost:3000
- App Router: http://localhost:3000/app-router/en
Uses i18next-locize-backend on the client side with i18next-chained-backend for localStorage caching. Server side uses bundled translations from public/locales/.
Uses resourceLoader with dynamic imports for server-side loading. Client-side uses I18nProviderWithLocize wrapper that configures the chained backend with Locize.
Handles language detection and routing for App Router pages, scoped to /app-router/* via basePath: '/app-router'.
This example uses the Locize project ID d3b405cf-2532-46ae-adb8-99e88d876733. Replace it with your own project ID to use your own translations.