JavaScript SDK (@unolio/sdk)
Official JavaScript SDK for Unolio: load translations at runtime in the browser, Node.js (18+), and any bundler-supported stack.
Contents
| Document | Description |
|---|---|
| Getting started | Install, env vars, and the minimal createClient → preload → t() flow |
| API reference | Types, UnolioClient methods, DOM helpers, and React exports |
| Script tag & DOM | UMD bundle, auto-init attributes, data-* targets, language switching |
| Framework integration | React, Next.js, Vite, Vue, Preact, Svelte — provider patterns and env |
The package README on npm duplicates quick-start examples and is the canonical entry for install metadata.
Package layout
| Import | Purpose |
|---|---|
@unolio/sdk | createClient, UnolioClient, translateDOM, switchLanguage |
@unolio/sdk/react | UnolioProvider, useUnolioClient, Trans, parseRichMessage, types |
Requires React ≥ 17 only if you use @unolio/sdk/react (peer dependency, optional).
Network & security
- The client calls
baseUrlwith paths/api/v1/translationsand/api/v1/languages, passingapiKeyas a query parameter. - Browser apps need CORS on your API for the app origin.
- Treat
NEXT_PUBLIC_*,VITE_*, and similar as public; use a server proxy if the key must stay secret.