Registry / storage / i18next-async-storage-backend

i18next-async-storage-backend

JSON →
library1.0.2jsnpmunverified

A caching layer backend for i18next that loads and caches translation resources from React Native's AsyncStorage. Version 1.0.2, last updated in 2019. Typically used in combination with the i18next Chained Backend to provide a primary cache with a fallback loader. Requires @react-native-community/async-storage as a peer dependency, which is deprecated in favor of @react-native-async-storage/async-storage. Minimal API surface; configuration via prefix, expiration time, and version objects.

npm install i18next-async-storage-backend
INSTALL
IMPORT
SIG · I18NEXT-ASYNC-STOR
I
i18next-async-storage-backend
storagejavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AsyncStorageBackend
import AsyncStorageBackend from 'i18next-async-storage-backend'
import { AsyncStorageBackend } from 'i18next-async-storage-backend'
Default export, not named
Backend (Chained)
import Backend from 'i18next-chained-backend'
import { Backend } from 'i18next-chained-backend'
Common pattern to use with Chained Backend; not part of this package
XHR Backend
import XHR from 'i18next-xhr-backend'
const XHR = require('i18next-xhr-backend').default
Common fallback; in CJS use .default or use require('i18next-xhr-backend').default

Shows basic setup with i18next Chained Backend using AsyncStorage as primary cache and XHR as fallback

import i18next from 'i18next'; import Backend from 'i18next-chained-backend'; import AsyncStorageBackend from 'i18next-async-storage-backend'; import XHR from 'i18next-xhr-backend'; i18next .use(Backend) .init({ lng: 'en', fallbackLng: 'en', backend: { backends: [ AsyncStorageBackend, XHR ], backendOptions: [ { prefix: 'i18next_res_', expirationTime: 7*24*60*60*1000, versions: { en: 'v1', fr: 'v1' } }, { loadPath: '/locales/{{lng}}/{{ns}}.json' } ] } }); i18next.on('initialized', () => { console.log('i18next ready:', i18next.t('key')); });
Debug
Known issues
deprecatedPackage uses deprecated @react-native-community/async-storage peer dependency
fix
Replace with @react-native-async-storage/async-storage and possibly patch the package to avoid peer warnings
affects: >=1.0.0
gotchaDefault export must be used; named import will fail
fix
Use `import AsyncStorageBackend from 'i18next-async-storage-backend'`
affects: >=1.0.0
gotchaPackage is not compatible with newer i18next v23+ due to internal API changes
fix
Use with i18next v22 or consider an alternative like i18next-localstorage-backend
affects: >=1.0.0
gotchaNo TypeScript types provided; manual type definition may be needed
fix
Add a .d.ts file or use @types/i18next-async-storage-backend if available
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Can't resolve '@react-native-community/async-storage'
Missing peer dependency or wrong package name (should be @react-native-async-storage/async-storage)
fix
npm install @react-native-async-storage/async-storage
TypeError: AsyncStorageBackend is not a constructor
Using named import instead of default import
fix
Change import to: import AsyncStorageBackend from 'i18next-async-storage-backend'
Error: backend namespace not loaded
i18next not using Chained Backend or backend not registered correctly
fix
Ensure i18next.use(Backend) is called before init and backends array includes AsyncStorageBackend and fallback
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
@react-native-community/async-storagerequiredPeer dependency for AsyncStorage access; deprecated in favor of @react-native-async-storage/async-storage
i18nextrequiredCore i18next library required for instantiation
i18next-chained-backendoptionalCommonly used together to implement fallback chain; this backend is typically the primary cache
Agent activity
10 hits · last 30 days
node
10
Resources
i18next-async-storage-backend — npm install i18next-async-storage-backend · libregistry