On this page
Migration guide
What changes in each major version of i18next, and the steps to move to it.
v26.x.x to v27.0.0
This is a major breaking release. It changes defaults that most setups had to override, gives every instance its own logger and post-processors, refuses language codes that look like markup or paths, and removes options that were broken or had no effect. For most of the runtime changes, i18next 26.7 logs a warning in debug mode (debug: true), so running your app once on 26.7 with debug logging finds most of what concerns you. It does not warn for returnEmptyString, addResources(), createInstance(), keySeparator: false or the TypeScript changes; read those sections below.
Keep the v26 behavior
Where an option exists, one line brings the v26 behavior back:
// the default escape of v26, '/' included
const entities = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
'/': '/',
};
i18next.init({
fallbackLng: 'dev', // better: your main language, e.g. 'en'
returnEmptyString: true, // an empty translation is a translation again
cleanCode: false, // keep codes without a region as they are ('EN' stays 'EN')
// escape '/' again
interpolation: {
escape: (str) => str.replace(/[&<>"'/]/g, (c) => entities[c]),
},
// a sentence for object hits
returnedObjectHandler: (key) =>
`key '${key}' returned an object instead of string.`,
});
declare module 'i18next' {
interface CustomTypeOptions {
strictInterpolationChecks: false;
returnEmptyString: true;
}
}
The other changes have no switch; they are described below.
Changed defaults
fallbackLngdefaults tofalseinstead of['dev'].devwas meant for thesaveMissingworkflow: missing keys went to a "developer language". Every app without afallbackLngtherefore requesteddevfrom its backend (with i18next-http-backend/locales/dev/translation.json, which almost no project has). Now i18next loads only the requested language (and its language part,deforde-CH), andsaveMissingsends missing keys for the current language. WithsupportedLngsand nofallbackLng, an unsupported language leaveslanguageandlanguagesunset, as an explicitfallbackLng: falsealready did in v26. SetfallbackLngto your main language;fallbackLng: 'dev'restores v26 exactly.returnEmptyStringdefaults tofalse: an empty translation falls back like a missing value (to the fallback language, thedefaultValueor the key), asnullalready did. This makes the default fit i18next-cli, whose extractor writes''for keys that are not translated yet in the other languages: those keys now fall back instead of rendering blank. An explicit''default from code still counts:t('key', '')andt('key', { defaultValue: '' })return''. If an empty translation is meant to render nothing in a language (an empty particle or suffix), setreturnEmptyString: true, ininit()and inCustomTypeOptions.- Language codes without a region get their canonical casing, as codes with a region already did (
'en-us'became'en-US'):'EN'becomes'en'. Only the casing changes: aliases liketl,iworengstay as they are ('TL'becomes'tl'), and so do codes that are not BCP 47, likeen_USormy_custom. i18next 26.7.0 and 26.7.1 warned that v27 turnsiwintoheortlintofil; that was wrong and 26.7.2 corrects it.iw,tland the like stay as they are. If your resources or translation files use upper case (EN), rename them to lower case, or setcleanCode: falseto keep codes without a region exactly as they are.cleanCodeis deprecated.
TypeScript
strictInterpolationChecksistrueby default.t()needs the options for a string with{{variables}}, so a variable cannot be left out of a call by accident (at runtime the raw{{name}}reaches the UI). It only concerns projects with typed resources. The three patterns that need a change:
// 'greeting': 'Hello {{name}}'
t('greeting'); // error since v27
t('greeting', { name: user.name }); // ok
// a wrapper that passes a key on to t() without options
// error once a string has variables
const label = (key: ParseKeys<'common'>) => t(key);
// type its key with ParseKeysWithoutVariables instead: only keys without
// variables
const plainLabel = (key: ParseKeysWithoutVariables<'common'>) => t(key); // ok
// variables filled in by interpolation.defaultVariables
declare module 'i18next' {
interface CustomTypeOptions {
defaultVariables: { appName: string }; // appName becomes optional in t()
}
}
A plural key needs count when its forms use it, also inside a union ((key: 'plain' | 'item') => t(key)), with getFixedT and when other options are passed (t('item', { defaultValue })). To keep the v26 types, set strictInterpolationChecks: false; with parseInterpolation: 'icu' or 'mf2' that also gives back the v26 types (their messages require their arguments either way).
returnEmptyStringisfalsein the types too, so a key whose value is''is typed as the key.compatibilityJSONis removed from the options andCustomTypeOptions. It had no effect since v24; remove it.keySeparator: falseinCustomTypeOptionsoffers only the flat keys (it producednestedfalsec-style keys and split keys at the textfalse), andkeyPrefixtakes the parts of the flat keys before a.('nested'for'nested.c'), sincegetFixedT()joins a key prefix with.. A key prefix combined with selectors is not typed for flat keys.- The internal helpers are no longer importable. Every declaration in
typescript/t.d.tsandtypescript/options.d.tscounted as exported, internal helpers included. The 86 helpers whose name starts with_or$are hidden now; every other type of those files (for exampleTOptionsBase,TFunctionSignature,ParseTReturn,DefaultTReturn,KeysBuilder,AppendKeyPrefix) is exported on purpose. If you imported one of the hidden helpers, please open an issue: exporting it again breaks nothing. The hidden names:$FirstNamespace,$IsResourcesDefined,$PluralBrand,$SelectorKeyBrand,$ValueIfResourcesDefined,_AllContextPrefixes,_ArgsFromEntries,_BuiltInFormatTypeMap,_ContextBases,_ContextPrefixes,_ContextPrefixesOf,_ContextSeparator,_CountIfPlural,_DefaultVariables,_DefinedContextKeys,_DefinedKeys,_DropConflictKeys,_EnableSelector,_FallbackNamespace,_FallbackParse,_HasContextVariant,_HasDefinedKey,_HasPlural,_IcuArg,_IcuArgsMap,_IcuBlock,_IcuCases,_IcuEntries,_IcuFormatType,_IcuSkipQuoted,_IcuStripQuotes,_IcuTrim,_IcuWhitespace,_IfOptionalDefaultOptions,_IfOptionalOptions,_InterpolationFormatSeparator,_InterpolationFormatTypeMap,_InterpolationMapFromEntries,_InterpolationPrefix,_InterpolationSuffix,_IsContextualKey,_IsLiteral,_KeyAndOptions,_KeySeparator,_KeysOf,_KeysWithoutVariables,_LegacyResources,_MergeNamespaces,_MergedResources,_Mf2ArgsMap,_Mf2Entries,_Mf2ExprEntries,_Mf2Expression,_Mf2FunctionType,_Mf2Locals,_Mf2Name,_Mf2Selectors,_Mf2Space,_Mf2Spaces,_Mf2StripEscapes,_Mf2Vars,_NonNeverKeys,_NsResourceStrict,_NsSeparator,_ParseInterpolation,_ParsesMessageFormat,_PerPropMerge,_PluralSeparator,_PrimaryParse,_RequiresMessageOptions,_ResolveEntryType,_Resources,_ReturnEmptyString,_ReturnNull,_ReturnObjects,_SelectorArrayOptionsArg,_SelectorOptionsArg,_SelectorsReturn,_StrictInterpolationChecks,_StrictKeyChecks,_StripFormatOptions,_UnescapePrefix,_UnescapeSuffix,_UnionToIntersection,_ValueOf,_WithDefaultVariables._CompatibilityJSONwas removed together withcompatibilityJSON. - Plugin option types belong to the plugins.
locizeLastUsedis declared by locize-lastused 5.1.0 and later.ReactOptionsstays importable from'i18next', but react-i18next fills it in (17.1.13 and later, and 18): thereactoptions are checked when react-i18next is part of the program.
Logger and post-processors per instance
In v26 the logger and the post-processors were shared by all instances: the init() of one instance rewired the logging of all others, and a post-processor use()d on one instance worked in every instance. Now they belong to the instance:
- An instance from
createInstance()does not see what the defaulti18nextinstance, or any other instance, registered. Calluse()on each instance.
Before (v26), this worked because the default instance registered sprintf for everybody:
import i18next from 'i18next';
import sprintf from 'i18next-sprintf-postprocessor';
i18next.use(sprintf);
const instance = i18next.createInstance();
await instance.init({ postProcess: 'sprintf' /* ... */ });
After (v27):
import i18next from 'i18next';
import sprintf from 'i18next-sprintf-postprocessor';
const instance = i18next.createInstance();
await instance.use(sprintf).init({ postProcess: 'sprintf' /* ... */ });
- A clone (
cloneInstance(), one per request with i18next-http-middleware) keeps the logger and the post-processors of its parent, also those its parent registers later. What a clone registers itself stays its own. - A plugin that calls
use()from its owninit()registers right away, as before. i18next.services.loggeris the instance's logger, withforward()as before.- In debug mode, a
postProcessname that is not registered on the instance logs a warning.
Language codes from outside
A language code from lng, changeLanguage(), a language detector or loadLanguages() that does not have the shape of isSafeLanguageCode() is refused, unless it is configured. The shape: letters, digits, -, _, @ and . (no ..), at most 128 characters, not a prototype key. Configured means listed in supportedLngs, in a fallbackLng that is not a function or in preload, or a language in resources, as given to init(); a fallbackLng function and languages added later (loadLanguages(), addResourceBundle()) do not count. Without supportedLngs, a detector that returned "><img src=x onerror=alert(1)> made that string i18next.language, which apps put into <html lang>, and backends were asked to load it.
changeLanguage() continues as with an unsupported code: with the detector's next code, else the fallback language, else none (with fallbackLng: false, a code refused at init() leaves language unset). loadLanguages() skips the code. BCP 47 (en-US, zh-Hant-TW, en-x-pirate), POSIX (en_US.UTF-8@euro, sr@latin) and other codes with _ pass. To use a code with other characters, for example b+sr+Latn, list it in supportedLngs. In debug mode a refused code logs a warning. With supportedLngs nothing changes for you: the input is matched as before ('de-DE;q=0.9' still gives 'de'), and only an unsafe match is refused, which only nonExplicitSupportedLngs can return ('de-<x>' for a supported 'de').
Output changes
/is no longer escaped. The default escape turned$10/monthinto$10/monthand dates in react-i18next'sTransinto17/12/2025.&,<,>,"and'are still escaped, which covers HTML text and quoted attributes; a/cannot end either. Update snapshot tests that contain/. A custominterpolation.escapeis not affected; one that escapes/too keeps the v26 output (see "Keep the v26 behavior" above).- An object or array without
returnObjectsis handled like a missing key:t()returns the default value if one is passed, else the key, withappendNamespaceToMissingKey,parseMissingKeyHandlerand the post-processors applied as for a missing key. It used to return the sentencekey 'obj (en)' returned an object instead of string., which ended up in the UI. The key is not saved as missing, since it exists. The debug warning stays;returnedObjectHandlerstill decides what is returned when it is set, so it can bring a sentence back. addResources()keeps every value. It added only strings and arrays and silently dropped numbers, booleans and nested objects.dir()without a language returns'ltr'(since 26.7.0).
createInstance(options)
createInstance(options) merges the defaults right away, without initializing the instance. Before init(), instance.options has the defaults (options.interpolation, overloadTranslationOptionHandler, ...), getFixedT() no longer throws, and with debug: true the warnings before init() are shown; t() returns '' until init(). A keySeparator or nsSeparator passed to createInstance() now counts as set by you, as if passed to init(). loadNamespaces() before init() does nothing and calls back. You still call init() as before; with a callback, createInstance(options, callback) initializes right away, as in v26.
keySeparator: false
With keySeparator: false keys are flat: a lookup no longer splits a key at the text false (t('nestedfalsec') returned the value of nested.c), and a selector path is joined with . like a key prefix. Selectors work on the flat keys: $ => $['a.b'] and $ => $.a.b look up the flat key 'a.b', and $ => $.nested.c no longer resolves nested, then c.
Removed
| Removed | Use instead |
|---|---|
getResource('en.translation.key'), addResource('en.translation.key', value), addResourceBundle('en.translation', resources) |
getResource('en', 'translation', 'key'), addResource('en', 'translation', 'key', value), addResourceBundle('en', 'translation', resources). The dotted form throws a TypeError in addResource(), addResources() and addResourceBundle(). A language code with a . (de_DE.UTF-8) is now a language like any other. |
interpolation.prefixEscaped, suffixEscaped, nestingPrefixEscaped, nestingSuffixEscaped (inserted into the RegExp unescaped) |
the literal delimiters as prefix, suffix, nestingPrefix, nestingSuffix |
compatibilityJSON (types) |
nothing, remove it |
locizeLastUsed and the body of ReactOptions (types) |
locize-lastused 5.1.0, react-i18next 17.1.13 or 18 |
the root index.js (a CommonJS shim the exports map made unreachable) |
require('i18next') |
For plugin authors
- Declare the calling convention of a backend or an async language detector with
callbackApi(since 26.7.0, see Plugins). Plugins without it still work in v27: i18next guesses from the number of parameters, which default and rest parameters change, and logs a deprecation warning in debug mode. The guessing is planned to go in a later major. - Reload through
services.utils.reloadResources()instead of callingbackendConnector.read()andloaded()yourself (since 26.7.0). - SSR integrations put server-rendered resources into the store with
hydrate()(since 26.7.0). WritingisInitialized,initializedStoreOnceandinitializedLanguageOncefrom outside still works in v27, so react-i18next 17'suseSSRkeeps working, but it is deprecated. - Use
isSafeLanguageCode()to check a language code from a request, a URL or storage with the same rule as core. services.backendConnector.backend,services.languageUtils,services.resourceStore,services.interpolatorand thecloneInstance()semantics are unchanged.
Support
- Node.js 22 or later (
engines). - The build targets ES2020 (Chrome and Edge 80, Firefox 80, Safari 14, Opera 67, Samsung Internet 13). It used browserslist
defaults, which changed with every update of the browser data; the output is the same as 26.7's. - TypeScript
^5 || ^6 || ^7, unchanged.
Changes from 26.x patches, in one place
- 26.4.7: a clone no longer inherits
preload. - 26.5.5: with
skipOnVariables(the default), a{{placeholder}}inside a value inserted with{{- var}}stays literal. - 26.5.10: the best match no longer picks a supported code that only starts with the same letters.
- 26.5.11 and 26.5.12: a nested
0,falseor''wins over a flat dotted key; a nestednullfalls back to it.
Selector API
Both APIs are supported, in the types too: string keys stay first-class, and the selector API (enableSelector) stays opt-in. The old note that v26 would turn on selectors by default and v27 would deprecate string-key types is withdrawn. Selectors help with very large namespaces and go-to-definition; see Selector API.
Companion releases
- react-i18next: on i18next 27, use react-i18next 17.1.13 or later, or 18; 17.x keeps working.
- i18next-cli: update to the release published with i18next 27.
- next-i18next: its peers already allow both majors.
Preparing for v27 (v26.7.0)
v26.7.0 is the last 26.x minor. With debug: true it logs a warning wherever a setup relies on something v27 changes, and most v27 defaults can be tried now with existing options:
i18next.init({
debug: true, // prints the warnings
// v27: fallbackLng defaults to false, set your source language (no implicit
// 'dev')
fallbackLng: 'en',
// v27 default: an empty string falls back like a missing key
returnEmptyString: false,
// close to v27, which canonicalizes codes without a region ('EN' becomes 'en')
cleanCode: true,
});
declare module 'i18next' {
interface CustomTypeOptions {
strictInterpolationChecks: true; // v27 default
returnEmptyString: false; // v27 default
}
}
With strictInterpolationChecks, type the key of a wrapper around t() with ParseKeysWithoutVariables and declare variables from interpolation.defaultVariables with the defaultVariables type option (see TypeScript). Plugin authors: declare callbackApi on backends and async detectors (see Plugins).
v25.x.x to v26.0.0
This is a major breaking release:
- Removed legacy
interpolation.formatfunction: the old monolithic format function (interpolation: { format: (value, format, lng) => ... }) is no longer supported. The built-in Formatter is now always used. For custom formatting, usei18next.services.formatter.add()or.addCached(), or provide a custom Formatter module via.use(). See the formatting docs. - Removed deprecated
initImmediateoption: useinitAsyncinstead (renamed in v24). - Removed console support notice: the
showSupportNoticeoption and all related internal suppression logic (globalThis.__i18next_supportNoticeShown,I18NEXT_NO_SUPPORT_NOTICEenv var) have been removed. i18next.formatnow always uses the Formatter:i18next.formatstill works, but it is backed by the built-in Formatter (or a custom Formatter module). It no longer accepts a user-supplied function viainterpolation.format.
Migration steps
- If you were using
interpolation: { format: function(value, format, lng) { ... } }, migrate your custom logic to the Formatter API:
// before (v25 and earlier)
i18next.init({
interpolation: {
format: function(value, format, lng) {
if (format === 'uppercase') return value.toUpperCase();
return value;
}
}
});
// after (v26)
i18next.init({ /* ... */ });
i18next.services.formatter.add('uppercase', (value, lng, options) => {
return value.toUpperCase();
});
- Replace any usage of
initImmediatewithinitAsync. - Remove any usage of
showSupportNoticefrom your init options.
v25.3.x to v25.4.0
- add new selector API to improve TypeScript IDE performance 2322
- To enable it, set
enableSelector: truein your configuration options - With
enableSelector: "optimize", i18next can now handle translation dictionaries of any size, without affecting IDE performance or build times - To assist with the migration, we've published the following packages:
- To enable it, set
v24.x.x to v25.0.0
This is a potentially breaking release:
- fix multiple
changeLanguagecalls that may have resulted in the wrong order in previous versions 1605 2298 - adapt
changeLanguageto always (string or array) usegetBestMatchFromCodes2299 getBestMatchFromCodesnow tries to fall back to a language code with the same script 2299
v23.x.x to v24.0.0
- remove support for older environments
- remove old i18next JSON formats
- to convert your existing v3 translations to the v4 format, have a look at i18next-v4-format-converter or its web tool.
- remove support for compatibility to the very first v1 API (old docs)
IntlAPI is mandatory now and will not fall back anymore; use a polyfill (Intl.PluralRulesandIntl.getCanonicalLocales) if your environment does not support it.- those who really need the old behavior need to create a compatibility layer similar to this.
- renamed
initImmediatetoinitAsync - fallback to
devlanguage if plural rule not found - Dropped support for Node.js < v14
TypeScript
- Now only
typescript >5versions are supported.v4types are now removed from the codebase. jsonFormatoption has been removed. When a new JSON version is released, you can use thecompatibilityJSONoption, which now only acceptsv4as value.
v22.x.x to v23.0.0
Redesigned TypeScript types
This PR redesigned the types to be less complex, faster and easier to maintain.\
The redesign endeavors to enhance the approach to parsing and inferring keys for the t function. Instead of performing a recursive examination of each key-value pair in resources associated with specific namespace(s) each time the t function is invoked, we generate a comprehensive set of keys from all namespaces just once.
Make sure your tsconfig compilerOptions has the strict flag or the strictNullChecks set to true.
Also use TypeScript v5.
Codemods
To assist with the upgrade from i18next v22.x.x to v23.0.0, Codemod provides open-source codemods that automatically transform your code to many of the new APIs and patterns.
The following codemods are available (see the notes in the "More information" section below):
More information: Features and Breaking changes
Features
- When loading multiple namespaces (react-i18next),
tfunction will infer and accept the keys for the first namespace. So this pattern will be accepted now:
tfunction will now infer and accept the keys for the main namespace (i18next):
- We're introducing a new type (
returnObjects) that will infer fewer keys if set tofalse, and all keys and sub-keys if set totrue. If the optionreturnObjectsfromtfunction is set totrue, it'll work the same way:
tfunction will now infer interpolation values, but it'll only work if the translation files (resources) are placed in a ts file and usingas const(like this) or an interface in a d.ts file, asi18next-cli typesgenerates it; JSON files don't supportas constto convert objects to be type literals (yet).
Breaking changes
All breaking changes described below are minor ones:
- Projects with the option
returnObjectsset astrueby default will also have to set the same option in theCustomTypeOptionstype. Otherwise, only complete keys will be allowed (key1.key2.key3...).
// i18next.d.ts
import 'i18next';
declare module 'i18next' {
interface CustomTypeOptions {
returnObjects: true
...
- Renaming
StringMapto$Dictionary, and we'll no longer export it.$Dictionaryis an internal helper, and there is no reason to expose it. If needed, you can create a copy and reuse it in your project. nsproperty fromInterpolationOptionstype will be constrained toNamespacerather thanstringorreadonly string[].
Codemod for this change:
npx codemod i18next/23/add-namespace-type-annotation
- Renaming
KeysWithSeparatortype toJoinKeys, and it will no longer be exposed.
Codemod for this change:
npx codemod i18next/23/replace-keys
- Renaming
TFuncKeytype toParseKeys. - Removing
NormalizeByTypeOptionstype. - Renaming
DefaultTFuncReturnWithObjecttype toDefaultTReturn. It will acceptTOptionsas generic constraint and will no longer be exposed.
Codemod for this change:
npx codemod i18next/23/remove-options
- Removing
DefaultTFuncReturntype in favor ofDefaultTReturn. - Removing
NormalizeReturntype.
If you encounter any issues, please report them to the Codemod team with npx codemod feedback
Removed setDebug function in internal logger
Based on this discussion we decided to remove the setDebug function.
Changed default value for returnNull option to false
To improve the usage for TypeScript users (in combination with React.js) we decided to set the returnNull value to false by default.
More information can be found here.
Dropped support for old browsers and Node.js < v12
To have smaller builds and faster loads, we now transpile only for modern browsers and runtimes.
More information can be found here.
Prefixed ordinal plural keys
To help translators, ordinal plural keys are now prefixed with _ordinal.
Older versions
Migrations from versions before v22 are on Older migrations.




