- Internationalized routing — Routing based on locale (sub-path or domain)
- Localization — Translating content based on the user’s preferred locale
Terminology
- Locale — An identifier for a set of language and formatting preferences:
en-US— English as spoken in the United Statesnl-NL— Dutch as spoken in the Netherlandsnl— Dutch, no specific region
Routing overview
Detect the user’s preferred locale using theAccept-Language request header and redirect to the appropriate locale path.
Detect and redirect
Use libraries like@formatjs/intl-localematcher and negotiator to match the best locale:
Dynamic locale segment
Nest all pages underapp/[lang]/ so the router passes the locale to every layout and page:
Localization
Translate content using dictionary files. Maintain separate JSON files per locale:getDictionary function to load translations:
Because all layouts and pages in
app/ default to Server Components, translation files do not increase the client-side JavaScript bundle size.Static rendering
Generate static routes for all locales usinggenerateStaticParams:
Libraries
For more advanced use cases, these libraries provide additional features like pluralization, date/number formatting, and React hooks:next-intl
Full-featured i18n with server and client support.
next-international
Type-safe i18n for App Router.
paraglide-next
Compile-time i18n with zero runtime overhead.
lingui
Comprehensive i18n with message extraction.
