Skip to content

saveMissing

When a component asks i18next for a key that does not exist, i18next can report it. The backend turns those reports into real keys in the editor, so new strings arrive from the code that needs them instead of from a ticket.

i18n.ts
await i18next.use(LocalizeBackend).init({
// ...
saveMissing: import.meta.env.DEV, // or process.env.NODE_ENV === 'development'
backend: {
projectSlug: 'your-project',
cdnBaseUrl: 'https://cdn.localize.work',
apiBaseUrl: 'https://api.localize.work',
apiKey: import.meta.env.VITE_LOCALIZE_PUBLIC_KEY, // public key kind
},
});

apiBaseUrl and apiKey are all-or-nothing: passing exactly one is an init error, passing neither makes reporting a silent no-op. The key must be the public kind — secret keys are rejected.

With saveMissing on, i18next reports a missing key and also writes the code default into its in-memory copy of the texts, creating objects along the key’s dotted path. In a project where keys sit under a text key (a text a next to a.b, published as described in published JSON format), that write can replace or hide published texts in memory, including keys written at the top level, until the page reloads. This happens in every i18next version; i18next before 23.8.2 can also throw from t() after the report is sent. Published files are never affected, and saveMissing is a development feature.

Batching. Every missing key seen in the same tick is coalesced per (locale, namespace) and flushed in a microtask, so a page that renders 200 missing keys sends a handful of requests, not 200.

Splitting. Each batch is split to stay inside the server’s limits:

LimitValue
Request body1 MiB
Entries per request1,000
Key length512 chars
Value length10,000 chars

Entries that cannot fit — an empty key, a key over 512 characters, a value over 10,000 — are dropped locally with one console.warn summarising the count, so a single bad entry never rejects the rest of the batch.

Failure policy. POST failures are warned about and otherwise swallowed. saveMissing must never break the host app, so nothing here throws or rejects.

Retries. 429 and 5xx are retried up to 3 attempts total, honouring Retry-After when present and otherwise backing off 250 ms, 500 ms. Other 4xx are not retried — they are configuration problems.

What the server does — the part the README does not tell you

Section titled “What the server does — the part the README does not tell you”

This is the half that surprises people. Full spec: POST missing keys.

An existing translation row is never overwritten, whatever value you post. A fallback string sitting in your JSX does not get to win over copy someone authored in the editor. Posting a key that already has a row increments existing in the response and changes nothing.

Posted locale Status of created rows
the project’s source locale reviewed — source text is authored, not translated
any target locale draft — a code fallback is a starting point, not a translation

Because only reviewed rows publish, keys arriving through saveMissing in a target locale will not appear on the CDN until a human reviews them. That is deliberate.

Some entries are skipped, quietly or loudly

Section titled “Some entries are skipped, quietly or loudly”
  • Empty value for a variant locale — skipped silently. Variants are sparse; an empty override means “inherit from the base locale”, which is already the default.
  • A plural form the locale does not use — skipped with a warning, e.g. posting items_few for a locale whose CLDR categories are only one/other.
  • Plural shape mismatch — posting items_one when items already exists as a non-plural key (or the reverse) is skipped with a warning.
  • A name another key publishes under — a new plural key items is skipped with a warning when a plain key named items_one (or like another of its forms) already exists, because both would publish under that name.

The body is a flat object of strings, so items_one / items_other arrive as separate entries; the server collapses them into one plural key, exactly like the import pipeline. _ordinal_* suffixes are not modelled and import as plain keys with a warning.

If creating new keys would take the organization over its key limit, the over-limit new keys are skipped, fills for keys that already exist still commit, and the response carries limitReached: true plus the limit. Nothing throws and nothing is rolled back — one over-limit key never discards the valid part of a batch.

(Import behaves the opposite way: it is all-or-nothing and returns a 402.)

{
"created": 12,
"existing": 340,
"warnings": ["\"items_few\": en does not use the \"few\" plural form — skipped"],
"limitReached": true,
"limit": 500
}

limitReached and limit appear only when the wall was hit. limit is null when the organization has an unlimited override.

Fixed 60-second window, counted per API key and per IP, because a public key is shared by every browser using it:

LimitValue
Window60 s (fixed)
Requests per API key60 / window
Requests per IP30 / window
Entries per API key2,000 / window
Entries per IP1,000 / window

Exceeding either dimension returns 429 with Retry-After. The SDK retries it.

POST {apiBaseUrl}/public/projects/{projectSlug}/missing/{locale}/{namespace}
https://api.localize.work/public/projects/your-project/missing/en/common
Authorization: Bearer lw_pub_…
Content-Type: application/json
{ "flat.key.name": "fallback value shown in code" }