On this page
Getting started
Your first translated text with i18next alone, in a few lines and without a framework.
Using a coding agent? Paste this prompt into Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI or any agent that can run terminal commands:
Prompt
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 t() 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
Installation
bash
npm install i18next
With yarn: yarn add i18next. Deno, a script tag from a CDN and the browsers i18next supports: Environments.
Basic sample
For an app, use a binding instead of setting innerHTML yourself: React, Next.js or Astro.
javascript
import i18next from 'i18next';
i18next.init({
lng: 'en', // if you're using a language detector, do not define the lng option
debug: true, // logs what i18next does to the console
resources: {
en: {
translation: {
"key": "hello world"
}
}
}
});
// ready at once: the resources were passed to init
document.getElementById('output').innerHTML = i18next.t('key');
Next steps
- The translation functions like interpolation, formatting and plurals.
- A binding for your framework: react-i18next, next-i18next, Astro or another framework.
- The configuration options.
- Your translators or tools expect ICU or MF2? Read Using ICU or MF2 before your files grow.
- Type-safe translations with TypeScript.
- A language detector to detect the preferred language of your user.
- A backend plugin to load the translations from the server or filesystem.
- A first machine translation of your files: translate.i18next.com.
- Missing translations or interpolation errors in your files: the free i18n health check.
- Hardcoded strings left in a GitHub repository: the free i18n readiness check.