Framework
Vite plugin
import verbaly from '@verbaly/vite';
export default { plugins: [verbaly({ sourceLocale: 'es' })] };Options are the same as the CLI config: sourceLocale, locales, dir, include, exclude, root. Inline options win over the config file.
How it compiles
t`Hola ${name}`becomest("x7Ka9q2f", { "name": name }), where the key is the content hash, stable across files.- The source locale ships inline; every other locale becomes its own lazy chunk, loaded on first
setLocale(). - Catalogs stay plain JSON: no proprietary format, portable to any TMS.
- Since
0.20.0this covers.svelteand.vuefiles too: script blocks and markup, including Svelte's$tstore form.
Dev server
- New texts are extracted as you type; catalogs and
verbaly.d.tsupdate with a debounce, then the dev server triggers a full page reload. - Editing a catalog JSON by hand invalidates the virtual modules automatically.
Build
The virtual module
import { t, verbaly, setLocale, getLocale, subscribe } from 'virtual:verbaly';
// SSR: request-scoped instances + locale metadata
import { createRequestInstance, createInstance, loadMessages, locales, sourceLocale } from 'virtual:verbaly';
// 0.17.0: fresh instance, catalog awaited, no flash. One call per request:
const v = await createRequestInstance(locale);
// 0.19.0: raw catalog for a locale (SSR integrations serialize it to the client):
const messages = await loadMessages(locale);The t/verbaly singleton is for the browser. On the server, createRequestInstance(locale) builds a fresh instance per request and awaits its catalog before returning: the no-FOUC contract in one call. createInstance(options) remains for custom setups (see Server-side).
verbaly.d.ts (generated at the project root) types this module: keys autocomplete and every key's params are enforced. Commit it so fresh clones type-check before the first dev run.
Not on Vite? Use @verbaly/unplugin
Since 0.10.0, @verbaly/unplugin brings the same compiler to webpack 5, Rollup, esbuild and Rspack: the typed virtual:verbaly module, the tagged-template transform and the build gate (failOnMissing: false opts out).
import { verbaly } from '@verbaly/unplugin';
export default { plugins: [verbaly.webpack({ locales: ['en', 'es'] })] };
// also: verbaly.rollup(…) · verbaly.esbuild(…) · verbaly.rspack(…)It's build-focused: run npx verbaly extract in your dev loop or CI, since live extraction and HMR remain this Vite plugin's value. ESM-only, like the compiler (use webpack.config.mjs).