Skip to main content
@hyperlocalise/ota loads a CDN distribution at runtime, so copy changes reach users without a new build. It works with any i18n library: the SDK returns plain message objects, and your library formats them. It has no dependencies and runs in browsers, Node 18+, React Native, Deno, Bun, and edge runtimes.

Install

Create a distribution in the JSON format and copy its hash from Settings → CDN.

How it works with your library

Every integration follows the same three steps:
  1. Create one client for the app.
  2. Load a locale’s messages with getMessages(locale) and give them to your library.
  3. Reload when a release goes out: subscribe to the client and give the library the new messages.
getMessages returns flat keys, exactly as they are in your source files:
The SDK does not parse or change the text. ICU, {{name}}, or any other placeholder syntax reaches your library as written. Libraries that look keys up by path need nested objects. Wrap the result in unflattenMessages:

react-intl

To avoid showing message ids on first render, start the state from your bundled messages, or render a loading state until the first getMessages resolves.

next-intl

Load messages on the server in i18n/request.ts. The client lives at module level, so requests share its cache, and it checks for a new release at most every 15 minutes. Don’t call startPolling on the server.

i18next

Add each namespace as a resource bundle. A namespace is a distributed file’s basename: /checkout.json is checkout.
To keep i18next’s default keySeparator, pass unflattenMessages(messages) to addResourceBundle instead.

vue-i18n

svelte-i18n

Any other library

Anything that accepts a messages object at runtime works the same way. Load with getMessages(locale), call unflattenMessages if the library expects nesting, and pass the result to the library’s “set” or “add messages” function. Run that function again in a subscribe listener. Libraries that compile catalogs at build time, such as Lingui, need their runtime compiler to use OTA strings.

Loading and locales

getMessages(locale) merges every file in the distribution for that locale. Pass { namespace: "checkout" } to read only /checkout.json. App locales resolve to the closest distribution locale: fr, fr_FR, and fr-CA all find fr-FR. getLocales() lists the distribution’s locales. Bundled fallbackMessages sit under OTA strings, so keys missing from the release still show your shipped copy.

New releases

The client reuses a manifest for 15 minutes and fetches locale files only when the release timestamp changes. startPolling() checks on that interval, and subscribe listeners run when a new release is found. You can set a longer pollIntervalMs, but not a shorter one. refresh() checks right away and resolves true when there is a new release.

Offline and revoked hashes

In browsers the release is saved in localStorage. On servers it is kept in memory. In React Native, pass AsyncStorage:
Use onError to log errors the client recovers from.

Custom S3 destinations

Pass the destination’s public base URL. The SDK requests {baseUrl}/{hash}/manifest.json:
On the Hyperlocalise CDN, the SDK tries api.hyperlocalise.com when public-api.hyperlocalise.com is unreachable.

Other formats

getMessages reads the JSON format. For Android XML or iOS strings distributions, getContent(locale) returns each file’s path, namespace, and raw body.

Next