# i18next-localstorage-backend

> caching layer backend for i18next using browsers localStorage

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

## Install

```sh
npm install i18next-localstorage-backend
pnpm add i18next-localstorage-backend
yarn add i18next-localstorage-backend
bun add i18next-localstorage-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 | 4.3.2 |
| 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 | 47.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 92 |
| Author | Jan Mühlemann |
| Maintainers | adrai, jamuhl |
| Keywords | i18next, i18next-backend |

## Links

- npm: https://www.npmjs.com/package/i18next-localstorage-backend
- Repository: https://github.com/i18next/i18next-localStorage-backend
- Issues: https://github.com/i18next/i18next-localStorage-backend/issues
- npm.io page: https://npm.io/package/i18next-localstorage-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

- 4.3.2 (latest) — 2026-07-28
- 4.3.1 — 2025-12-04
- 4.3.0 — 2025-12-03
- 4.2.0 — 2023-09-15
- 4.1.1 — 2023-04-07
- 4.1.0 — 2022-12-10
- 4.0.1 — 2022-11-25
- 4.0.0 — 2022-10-26
- 3.1.3 — 2021-06-17
- 3.1.2 — 2020-09-29
- 3.1.1 — 2020-02-22
- 3.1.0 — 2020-02-20
- 3.0.0 — 2019-06-03
- 2.1.2 — 2019-02-18
- 2.1.1 — 2019-02-15
- … 6 more at https://npm.io/package/i18next-localstorage-backend/versions

## README

# Introduction

This is a i18next cache layer to be used in the browser. It will load and cache resources from localStorage and can be used in combination with the [chained backend](https://github.com/i18next/i18next-chained-backend).

## 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_localstorage_backend_readme&utm_medium=github&utm_campaign=readme), take a look at [i18next-locize-backend](https://github.com/locize/i18next-locize-backend) — pair it with this localStorage cache layer for instant client-side reads + always-current translations from a global CDN. The i18next [backend plugin](https://www.i18next.com/overview/plugins-and-utils#backends) for 🌐 [Locize](https://www.locize.com?utm_source=i18next_localstorage_backend_readme&utm_medium=github&utm_campaign=readme) ☁️.

# Getting started

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

- If you don't use a module loader it will be added to window.i18nextLocalStorageBackend

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

Wiring up with the chained backend:

```js
import i18next from 'i18next';
import Backend from 'i18next-chained-backend';
import LocalStorageBackend from 'i18next-localstorage-backend'; // primary use cache
import HttpApi from 'i18next-http-backend'; // fallback http load

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

## Cache Backend Options


```js
{
  // prefix for stored languages
  prefix: 'i18next_res_',

  // expiration
  expirationTime: 7*24*60*60*1000,

  // Version applied to all languages, can be overridden using the option `versions`
  defaultVersion: '',

  // language versions, can be overridden using the `getVersion` function
  versions: {},

  // language/namespace version getter
  getVersion: (lng, ns) => '',

  // can be either window.localStorage or window.sessionStorage. Default: window.localStorage
  store: typeof window !== 'undefined' ? window.localStorage : null
};
```

- Contrary to cookies behavior, the cache will respect updates to `expirationTime`. If you set 7 days and later update to 10 days, the cache will persist for 10 days

- Passing in a `versions` object (ex.: `versions: { en: 'v1.2', fr: 'v1.1' }`) or `getVersion` function (ex.: `getVersion: (lng, ns) => `${lng}-${ns}-v1.1`})`) will give you control over the cache based on translations version. This setting works along `expirationTime`, so a cached translation will still expire even though the version did not change. You can still set `expirationTime` far into the future to avoid this. Note that the `getVersion` function takes precedence over the `versions` object if both are provided.

- Passing in a `defaultVersion` string (ex.: `version: 'v1.2'`) will act as if you applied a version to all languages using `versions` option.

- The test on window makes this package available for SSR environments like NextJS

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

We suggest not to use a caching layer 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_localstorage_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_localstorage_backend_readme&utm_medium=github&utm_campaign=readme) you directly support the future of i18next and react-i18next.

---

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