next-i18next is an internationalization library that integrates the i18next ecosystem into Next.js applications, supporting both the App Router and Pages Router. It provides locale-aware routing middleware, server-component translation hydration, and a unified translation management system that works across server and client components.
The library handles automatic language detection from browser cookies and HTTP Accept-Language headers, persists user language preferences across sessions, and rewrites URLs with locale prefixes for proper routing. It includes a translation hydration framework that serializes server-loaded translations into page HTML, enabling immediate client-side access without additional network requests. For mixed-router projects, it provides separate middleware and configuration paths that allow both routing systems to coexist.
Translation resources can be loaded from local JSON files or external sources through any i18next backend plugin, including HTTP, Locize, or chained backends. The library supports client-side language switching without full page reloads and provides dedicated translation functions for both Server Components and Client Components.