v7.0.0: A backend plugin for i18next that loads translation resources using the browser's Fetch API, suitable for modern browsers and Service Worker contexts. The package ships TypeScript types and requires Node >=20. It replaces XMLHttpRequest-based backends, offering native promise support and compatibility with fetch options like CORS and credentials. Release cadence is irregular; the latest major version removed deprecated callback-based fetch in favor of a function returning a Promise.
npm install i18next-fetch-backendNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic initialization of i18next with the fetch backend, loading translations from /locales/{{lng}}/{{ns}}.json with CORS options.
Update Node to >=20 and migrate from `require` to `import`.
Replace `fetch: function(url, options, callback) { ... callback(null, data); }` with `fetch: async (url, options) => { ... return data; }`.Refer to i18next documentation for multiloading patterns.
In Service Workers, fetch is available globally; but if not, import a fetch polyfill before using the backend.
Install a fetch polyfill like `cross-fetch` or `node-fetch` and assign to global scope before importing i18next-fetch-backend.
Ensure loadPath starts with '/' or a full URL. Use a function to dynamically construct the path if needed.