# i18next-chained-backend

> backend layer for i18next to chain backends

Latest version **5.0.6** (published 2026-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install i18next-chained-backend
pnpm add i18next-chained-backend
yarn add i18next-chained-backend
bun add i18next-chained-backend
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.6 |
| Published | 2026-07-28 |
| First published | 2018-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 71.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 78 |
| Author | Jan Mühlemann |
| Maintainers | adrai, jamuhl |
| Keywords | i18next, i18next-backend |

## Links

- npm: https://www.npmjs.com/package/i18next-chained-backend
- Repository: https://github.com/i18next/i18next-chained-backend
- Issues: https://github.com/i18next/i18next-chained-backend/issues
- npm.io page: https://npm.io/package/i18next-chained-backend

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.28.4

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 5.0.6 (latest) — 2026-07-28
- 5.0.5 — 2026-06-11
- 5.0.4 — 2026-05-08
- 5.0.3 — 2026-03-23
- 5.0.2 — 2026-01-20
- 5.0.1 — 2026-01-19
- 5.0.0 — 2026-01-16
- 4.6.3 — 2025-12-27
- 4.6.2 — 2023-11-10
- 4.6.1 — 2023-11-10
- 4.6.0 — 2023-11-10
- 4.5.0 — 2023-09-15
- 4.4.0 — 2023-06-15
- 4.3.0 — 2023-06-08
- 4.2.0 — 2022-12-10
- … 15 more at https://npm.io/package/i18next-chained-backend/versions

## README

# Introduction

[![npm version](https://img.shields.io/npm/v/i18next-chained-backend.svg?style=flat-square)](https://www.npmjs.com/package/i18next-chained-backend)

This is a i18next backend to chain multiple [other backends](https://www.i18next.com/overview/plugins-and-utils#backends) and caches. So you can define an additional caching backend or fallback backends.

Usage examples for caching configurations can be found [here](https://www.i18next.com/how-to/caching) and for fallback backends can be found [here](https://www.i18next.com/how-to/backend-fallback).

## How it works

For each [backend read call](https://www.i18next.com/misc/creating-own-plugins#backend) (so for each language and namespace combination), it will try to read from from all backends in order until a backend returns some resources.
So if it does not find the resource (language + namespace) in the first backend, it goes to the next, etc.

## Advice:

If you don't like to manage your translation files manually or are simply looking for a [better management solution](https://www.locize.com?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme), take a look at [i18next-locize-backend](https://github.com/locize/i18next-locize-backend) — it works as one of the chained backends (typically the network fallback). The i18next [backend plugin](https://www.i18next.com/overview/plugins-and-utils#backends) for 🌐 [Locize](https://www.locize.com?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme) ☁️.

Starting from an app with hardcoded strings? Run `npx i18next-cli localize` — one command that wraps strings in `t()`, extracts keys, connects to [Locize](https://www.locize.com?from=i18next-chained-backend_readme__localize) and AI-translates your app. See the [launch post](https://www.locize.com/blog/i18next-cli-localize?from=i18next-chained-backend_readme__localize).

# Getting started

Source can be loaded via [npm](https://www.npmjs.com/package/i18next-chained-backend) or [downloaded](https://github.com/i18next/i18next-chained-backend/blob/master/i18nextBackendBackend.min.js) from this repo.

```
# npm package
$ npm install i18next-chained-backend
```

Wiring up:

```js
import i18next from 'i18next';
import Backend from 'i18next-chained-backend';

i18next
  .use(Backend)
  .init(i18nextOptions);
```

- As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
- If you don't use a module loader it will be added to `window.i18nextChainedBackend`

## Backend Options

```js
{
  // array of existing i18next backends from https://www.i18next.com/overview/plugins-and-utils#backends
  backends: [],

  // array of options in order of backends above
  backendOptions: []
}
```

Options can be passed in:

**preferred** - by setting options.backend in i18next.init:

```js
import i18next from 'i18next';
import Backend from 'i18next-chained-backend';

i18next
  .use(Backend)
  .init({
    backend: options
  });
```

on construction:

```js
  import Backend from 'i18next-chained-backend';
  const Backend = new Backend(null, options);
```

via calling init:

```js
  import Backend from 'i18next-chained-backend';
  const Backend = new Backend();
  Backend.init(null, options);
```

### caching example

```js
import i18next from 'i18next';
import Backend from 'i18next-chained-backend';
import LocalStorageBackend from 'i18next-localstorage-backend'; // load from local storage
import HttpApi from 'i18next-http-backend'; // have a own http fallback

i18next
  .use(Backend)
  .init({
    backend: {
      backends: [
        LocalStorageBackend,  // primary
        HttpApi  // fallback
      ],
      backendOptions: [{
        projectId: 'myLocizeProjectId'
      }, {
        loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback
      }],
      // cacheHitMode: 'none' // (default)
      // cacheHitMode: 'refresh' // tries to refresh the cache by loading from the next backend and updates the cache
      // cacheHitMode: 'refreshAndUpdateStore' // tries to refresh the cache by loading from the next backend, updates the cache and also update the i18next resource store
      // reloadInterval: 60 * 60 * 1000 // can be used to reload resources in a specific interval (useful in server environments)
      // refreshExpirationTime: 7 * 24 * 60 * 60 * 1000 // In case of caching with 'refresh' or 'refreshAndUpdateStore', it will only fetch from the next backend if the cached namespace is expired. Only supported if the backend returns the saved timestamp, like i18next-fs-backend, i18next-localstorage-backend
      // retryOnFailure: true // signals i18next to retry the read (with its default backoff behaviour) when none of the chained backends was able to load the requested namespace. Keep it disabled (default) if missing namespaces are expected (e.g. when relying on fallback languages), since retries would delay the fallback resolution
    }
  });
```

### more complete sample

```js
import i18next from 'i18next';
import Backend from 'i18next-chained-backend';
import Locize from 'i18next-locize-backend'; // load from service
import HttpApi from 'i18next-http-backend'; // have a own http fallback

i18next
  .use(Backend)
  .init({
    backend: {
      backends: [
        Locize,  // primary
        HttpApi  // fallback
      ],
      backendOptions: [{
        projectId: 'myLocizeProjectId'
      }, {
        loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback
      }]
    }
  });
```

*More [locize](https://www.locize.com?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme) examples can be found here:*
- *[Caching](https://www.locize.com/docs/caching/alternative-caching-with-i18next?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme)*
- *[Backend Fallback](https://www.locize.com/docs/backend-fallback?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme)*
- *[Multiple projects in same i18next instance](https://www.locize.com/docs/general-questions/is-it-possible-to-integrate-multiple-projects-in-the-same-app-website?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme)*

## TypeScript

To properly type the backend options, you can import the `ChainedBackendOptions` interface and use it as a generic type parameter to the i18next's `init` method, e.g.:

```ts
import i18n from 'i18next'
import ChainedBackend, { ChainedBackendOptions } from 'i18next-chained-backend'

i18n
  .use(ChainedBackend)
  .init<ChainedBackendOptions>({
    backend: {
      backends: [
        Locize,  // primary
        HttpApi  // fallback
      ],
      backendOptions: [{
        projectId: 'myLocizeProjectId'
      }, {
        loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback
      }]
    }

    // other i18next options
  })
```

## IMPORTANT ADVICE for the usage in combination with saveMissing/updateMissing

We suggest not to use mutliple backends in combination with saveMissing or updateMissing, because it may happen, that the trigger for this is based on stale data.


--------------

<h3 align="center">Gold Sponsors</h3>

<p align="center">
  <a href="https://www.locize.com?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme" target="_blank">
    <img src="https://raw.githubusercontent.com/i18next/i18next/master/assets/locize_sponsor_240.gif" width="240px">
  </a>
</p>

---

**localization as a service - locize.com**

Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next!

![Locize](https://www.locize.com/img/ads/github_locize.png)

With using [Locize](https://www.locize.com/?utm_source=i18next_chained_backend_readme&utm_medium=github&utm_campaign=readme) you directly support the future of i18next and react-i18next.

---

---
_Source: https://npm.io/package/i18next-chained-backend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
