Guides
Server-side
The core runs anywhere JavaScript does, including Node. Create an instance, pass the locale, call t(). No DOM required.
One instance per request
Build a fresh instance per request and hand it the visitor's locale. negotiateLocale reads the Accept-Language header and picks the best match among your locales (it understands quality values, and es-PE matches es). resolveRequestLocale (0.17.0) makes the whole decision in one call: cookie first, then the header, then your fallback. Instances don't share state, so two requests never mix their languages.
import { createVerbaly, negotiateLocale } from 'verbaly';
import es from './locales/es.json';
import en from './locales/en.json';
function handle(req) {
const locale = negotiateLocale(req.headers['accept-language'], ['en', 'es']);
const v = createVerbaly({ locale, fallback: 'en', messages: { en, es } });
return v.t('home.title');
}Render HTML ahead of time
For static sites, verbaly render pre-fills your built HTML per locale so pages ship already translated. See CLI → Static rendering.
Meta-frameworks
On SvelteKit, Nuxt and Next.js you don't wire any of this by hand: the SvelteKit integration, the Nuxt module and the Next.js integration negotiate the locale per request and hydrate without a flash, all on these same primitives.