Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init history"v9.0.013/06/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Migrate from react-i18next to Intlayer
For a complete and detailed step-by-step tutorial, please see our full react-i18next Migration Guide.
Using Intlayer's compat adapter allows you to migrate from react-i18next without any changes to your source code imports.
What to do
To initialize the project, run:
Copy the code to the clipboard
npx intlayer initDuring initialization, Intlayer will install @intlayer/react-i18next and create intlayer.config.ts. In your bundler (like Vite), apply the Intlayer plugin:
Copy the code to the clipboard
import { defineConfig } from "vite";import react from "@vitejs/plugin-react";import { reactI18nextVitePlugin } from "@intlayer/react-i18next/plugin";export default defineConfig({ plugins: [react(), reactI18nextVitePlugin()],});What it does under the hood
The reactI18nextVitePlugin wraps the core vite-intlayer plugin and injects resolve aliases for react-i18next and i18next, redirecting them to @intlayer/react-i18next and @intlayer/i18next.
Under the hood:
useTranslation&withTranslation: Rewritten to use Intlayer's native hooks, giving you automatic TypeScript completion for your dictionary keys. It seamlessly supports namespaces (e.g.t('namespace:key')).- Plurals & Context: Handles i18next's suffix-based pluralization (
key_one,key_other) using nativeIntl.PluralRulesand context suffixes (key_male). <Trans>Component: Re-implemented to support thecomponentsprop, object and array forms, and numbered tags<1>...</1>directly mapping to your React nodes.i18ninstance: Resolves keys directly from Intlayer without fetching large JSON files, resulting in significantly lower bundle sizes.