i18next-http-backend

An i18next backend plugin that loads translation resources over HTTP using fetch or XMLHttpRequest, for Node.js, browsers, and Deno.

Library
npm
v4.0.5
527 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
72 /100 Good
Development Activity 88
Maintenance 44
Community 68
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 78
Code Quality 82
Innovation 74
Learning Curve 65

i18next-http-backend is the standard HTTP-loading backend for i18next, the widely used JavaScript internationalization framework. Registered with i18next.use(Backend), it fetches translation JSON from a configurable loadPath template (a static string or a function returning one), interpolates the requested language and namespace into the URL, and hands the parsed result back to i18next’s backend connector — including retry signaling on network failures and 5xx responses.

As of v4 it requires native fetch (Node >=18, modern browsers, Deno, Bun) and no longer bundles a cross-fetch polyfill, though it still supports XMLHttpRequest as a fallback transport and exposes an alternateFetch hook for supplying a ponyfill or intercepting requests (useful for testing or auth-header rewriting). It also supports posting missing translation keys back to a server via addPath, and can transparently reload resources on an interval for long-running server processes.

What You Get

  • Drop-in i18next backend — a single i18next.use(Backend).init(...) call with a loadPath template string like /locales/{{lng}}/{{ns}}.json
  • Dual transport support — native fetch by default, automatic fallback to XMLHttpRequest in environments without fetch, and an alternateFetch override for ponyfills or test mocking
  • Cross-runtime by design — the same package works in Node.js, browsers (including a standalone CDN/UMD build), and Deno with a dedicated import path
  • Missing-key reporting — addPath plus saveMissing: true on i18next posts untranslated keys back to a server endpoint for translators to fill in
  • Hardened URL interpolation — language and namespace values are validated against a safety allowlist before being substituted into request URLs, blocking path traversal, scheme confusion, and log-injection patterns
  • Configurable retry and reload behavior — automatic retry on 5xx/network errors, and an optional interval timer to re-fetch resources in long-lived server processes

Common Use Cases

  • Loading translation JSON files from a static /locales/{lng}/{ns}.json path served alongside a web app
  • Serving translations from a dedicated backend API, with per-request auth headers via customHeaders
  • Server-side rendering setups (Next.js, Node) where a single i18next instance is created once per process, avoiding per-request backend instantiation
  • Feeding missing-translation workflows where untranslated keys discovered at runtime are posted to a management endpoint via addPath
  • Testing i18next-dependent code by swapping in a mocked alternateFetch implementation instead of monkey-patching global fetch

Under The Hood

Architecture

The Backend class in lib/index.js implements i18next’s plugin contract (type = 'backend', read/readMulti/create/reload) and is instantiated by i18next core when passed to .use(). read() funnels into _readAny, which resolves loadPath (a string or a function that may itself return a promise, via makePromise), interpolates the URL template through interpolateUrl in lib/utils.js, and calls loadUrl, which invokes options.request — defaulting to the function exported from lib/request.js — and translates HTTP status codes and thrown errors into retry/no-retry signals fed back to i18next’s backendConnector. reload() implements an optional interval-based refresh using services.backendConnector and languageUtils, unref’d so it never keeps a Node process alive on its own. The whole design centers on one swappable seam — the request(options, url, payload, callback) signature — which is the sanctioned way to fully replace the transport layer.

Tech Stack

Zero runtime dependencies; v4 dropped the bundled cross-fetch ponyfill and now requires native fetch (Node >=18). Dev tooling includes ESLint 9 with the neostandard config, Mocha with expect.js for assertions, tsdown to build dual ESM/CJS output driven by the package.json exports map, tsd to type-test the hand-authored .d.ts/.d.mts declarations, and a Node xmlhttprequest polyfill used only to exercise the XHR code path in test. A minified UMD bundle (i18nextHttpBackend.min.js) is checked into the repo root and also distributed via jsDelivr/unpkg for plain-<script> consumption.

Code Quality

The test suite (over 600 lines across backendConnector.load.spec.js, http.spec.js, request.spec.js, and security.spec.js) runs the fetch code path and the XHR code path as separate suites, plus a dedicated Deno test directory executed in its own GitHub Actions workflow alongside a Node matrix covering versions 20, 22, and 24. security.spec.js specifically targets the URL-interpolation safety logic — isSafeLangUrlSegment/isSafeNsUrlSegment in lib/utils.js — with inline comments citing a real security advisory for the path-traversal and scheme-confusion issue those guards close. Error handling in request.js explicitly distinguishes network failures, 4xx/5xx responses, and JSON parse errors rather than swallowing them, and TypeScript types are hand-written and validated with tsc --noEmit plus tsd rather than auto-generated.

API Design Getting started is a single .use(Backend) call plus a loadPath string, matching i18next’s plugin convention exactly, so the common case has near-zero boilerplate. Advanced behavior — missing-key posting, multi-language/namespace batching via readMulti, or full request/response interception via a custom request function — layers on top of the same flat options object instead of requiring subclassing. Naming and shape are consistent with the rest of the i18next backend ecosystem (i18next-fs-backend, i18next-chained-backend), which keeps the learning curve low for anyone already using another i18next backend plugin.

Used by 25 apps in this directory

TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,196

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 6 days ago
JavaScript
42%
Other

LimeSurvey

Forms Surveys

3,778

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript 42%
PHP 36%
CSS 12%
Updated 6 days ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,686

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 6 days ago
Go
74%
Apache 2.0

ntfy

Developer Tools · Marketing

35,022

Send push notifications to your phone or desktop from any script or service using a single HTTP PUT or POST—no sign-up required.

View details
90
Repo Health
89
Technical
75
Dependency
Built with
Go 74%
JavaScript 25%
Updated 1 weeks ago
TypeScript
92%
Other

OpenHands

AI Code Assistants · AI Development

91,695

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 92%
Updated 1 weeks ago
JavaScript
90%
Other

OpenSign

Digital Signiture

7,163

Self-host a full-featured DocuSign alternative with unlimited e-signatures, multi-signer workflows, and cryptographic PDF signing.

View details
83
Repo Health
61
Technical
69
Dependency
Built with
JavaScript 90%
Updated 1 weeks ago
TypeScript
98%
Other

Outline

Collaboration · Knowledge Management

41,045

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
51%
ZLIB

Portainer

Devops

38,707

A lightweight, open-source web UI that puts Docker, Kubernetes, and Podman management within reach of any team—no CLI expertise required.

View details
93
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 51%
Go 38%
Updated 1 weeks ago
Rust
63%
MIT

Readur

Bookmarks Archiving · File Storage · Knowledge Management

804

A self-hosted document management system that OCRs, indexes, and makes every PDF, scan, and Office file instantly searchable.

View details
83
Repo Health
78
Technical
67
Dependency
Built with
Rust 63%
TypeScript 32%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers