View as Markdown
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