Skip to content

Options

Everything below goes in backend: { … } inside i18next.init().

The table is generated at documentation build time from the TSDoc in the published type declarations of @localize-work/[email protected]. If an option is added to the SDK and not documented here, this site fails to build.

OptionTypeRequiredDescription
projectSlugstringyesProject slug as it appears in CDN paths and API routes.
cdnBaseUrlstringyesCDN origin, e.g. https://cdn.localize.work.
versionstring—Release to load: an immutable version like 'v3', or 'latest' (default).
apiBaseUrlstring—API origin for saveMissing, e.g. https://api.localize.work. Missing keys are only reported when BOTH apiBaseUrl and apiKey are set.
apiKeystring—Public (read/saveMissing) API key. Dev-only — never ship it enabled to prod.
trackUsageboolean | TrackUsageOptions—Report which keys the app looks up, so the editor can show unused keys. Dev/staging only. Needs apiBaseUrl and apiKey. true uses the defaults; an object adjusts them. In a browser, keys are only reported on the hosts in allowedHosts (by default localhost, 127.0.0.1 and [::1]); where there is no web address at all (server rendering, React Native) they are reported whenever this is on. Each key is sent at most once per page load. @see https://localize.work/docs/sdk/usage-tracking/
strictboolean—When true, a 404 for a namespace file is reported as a load error. By default a 404 resolves to an empty resource: variant locales (en-FI over en) publish sparse files, so an absent namespace is a normal condition.
fetchOptionsRequestInit—Extra fetch options merged into every CDN request (headers, cache, …).
loadPathLoadPath—Escape hatch overriding the whole CDN URL: a template with {{lng}} and {{ns}} placeholders, or a function (language, namespace) => url.
onFailedLoad(info: FailedLoadInfo) => void—Observability hook — called on every failed CDN load, including sparse 404s.

These are enforced at init() and throw synchronously, so a misconfiguration fails at startup rather than as silent 404s at runtime. Every message is prefixed [@localize-work/i18next-backend].

cdnBaseUrl is required unless loadPath is set

Section titled “cdnBaseUrl is required unless loadPath is set”

projectSlug is always required — it identifies the project for saveMissing even when you have overridden the URL entirely. cdnBaseUrl is only required when loadPath is absent. Setting both is allowed: loadPath wins for reads.

Omitting both raises `cdnBaseUrl` must be a non-empty string.

Passing exactly one of them is an init error, not a warning:

saveMissing needs BOTH apiBaseUrl and apiKey — only one was provided. Omit both to disable missing-key reporting.

Passing neither is the normal production configuration: create() becomes a silent no-op.

It is an observability hook, nothing more. It fires on every failed CDN load, including the sparse 404s that are a normal condition for variant locales — so if you route it into an error tracker, filter status === 404 or you will page yourself over correct behaviour.

Its argument:

FieldTypeAlways presentDescription
urlstringyes
languagestringyes
namespacestringyes
statusnumber—HTTP status when a response was received; absent on network errors.
errorunknown—The thrown value on network/parse failures; absent on plain HTTP errors.

Default (false): a 404 resolves to an empty resource and i18next’s fallbackLng chain supplies the values. With strict: true, a 404 calls back with an error and no retry. Everything else about failure handling is identical.

The string form substitutes {{lng}} and {{ns}}, URL-encoding both. The function form receives (language, namespace) and must return a complete URL. When loadPath is set, the pointer is never fetched — you are responsible for versioning.

backend: {
projectSlug: 'your-project',
loadPath: 'https://static.example.com/i18n/{{lng}}/{{ns}}.json',
// or: loadPath: (lng, ns) => `https://static.example.com/i18n/${lng}/${ns}.json`,
}