i18next backend
@localize-work/i18next-backend is an i18next backend
plugin. It fetches
published JSON straight from the CDN and — in development only — reports missing
keys back to the API.
It works in browsers and in Node 18+. It uses global fetch and has no HTTP
dependency; i18next is its only peer dependency (^23 || ^24 || ^25 || ^26 || ^27).
i18next 27 is supported from SDK 0.11.1 and itself needs Node 22 or later.
It also runs in React Native, Hermes included: it needs only the global
fetch, and doesn’t use TextEncoder, URL or the DOM, which older Hermes
releases lack. In-context editing needs a browser, so
don’t import @localize-work/i18next-backend/in-context in a React Native app.
If you turn on key usage tracking there, turn it on
only in development builds: an app has no hostname to tell development from
production by.
- npm:
@localize-work/i18next-backend— current version 0.11.1, MIT - source: github.com/localize-work/localize-work-i18next-backend
Install
Section titled “Install”pnpm add i18next @localize-work/i18next-backend# react apps: pnpm add react-i18nextMinimal working init
Section titled “Minimal working init”import i18next from 'i18next';import { initReactI18next } from 'react-i18next';import LocalizeBackend from '@localize-work/i18next-backend';
await i18next.use(LocalizeBackend).use(initReactI18next).init({ lng: 'et', fallbackLng: 'en', ns: ['common', 'app'], defaultNS: 'common', backend: { projectSlug: 'your-project', cdnBaseUrl: 'https://cdn.localize.work', },});The plugin is also exported as a named export, LocalizeBackend, if you prefer
that to the default.
What it does
Section titled “What it does”- Resolves
latest.jsononce per backend instance, then reads every locale and namespace at that one version, so a publish landing mid-startup cannot give you a half-and-half resource set. - Classifies failures for i18next’s retry logic: 2xx → data; 404 → empty resource (a normal condition for variant locales); other 4xx → error, no retry; 5xx and network errors → error, retry allowed.
- Batches
saveMissingreports per(locale, namespace)and posts them — only when bothapiBaseUrlandapiKeyare configured. See saveMissing.
What it does not do
Section titled “What it does not do”- No caching layer. It calls
fetch. UsefetchOptionsto hand the browser or Node cache your own directives; the CDN already sets long-livedCache-Controlon immutable paths. - No bundling or offline snapshot. If you need translations inside your
build artifact, fetch them at build time and hand them to i18next as
resources— the files are plain JSON with no auth. - No polling. Picking up a newer release means re-initialising i18next.
- No writes other than saveMissing. Nothing in this package can change a translation.
Debugging: the exact URL
Section titled “Debugging: the exact URL”cdnUrl() is exported so you can print what the backend will fetch:
import { cdnUrl } from '@localize-work/i18next-backend';
cdnUrl({ cdnBaseUrl: 'https://cdn.localize.work', projectSlug: 'your-project', version: 'v12' }, 'et', 'common');// https://cdn.localize.work/your-project/v12/et/common.jsonlatestManifestUrl() and missingUrl() are exported for the same reason.
Version pinning, briefly
Section titled “Version pinning, briefly”version defaults to 'latest', which follows the pointer. Pass an immutable
version to freeze a deploy to an exact release:
backend: {projectSlug: 'your-project',cdnBaseUrl: 'https://cdn.localize.work',version: 'v12', // exact release, never changes}A rollback on our side moves the pointer; pinned applications are unaffected in either direction. Inject the version at build time if you want deploy-locked translations without editing source.
- Options reference — every option, generated from the package’s own type declarations.
- Variant locales — read this before treating a 404 as a bug.
- saveMissing — dev-only missing-key reporting.