@verbaly/nuxt
Server-rendered pages arrive already translated in the visitor's language (the address first when your URLs carry it, then the cookie, then Accept-Language, then your fallback) and the client hydrates with the same locale and the same catalog, so there's no flash of untranslated text and no hydration mismatch. Each request gets its own instance: no locale leaking between concurrent users.
One line in nuxt.config wires everything: the Vite plugin (live extraction + the virtual:verbaly module), the per-request negotiation and <html lang>/<html dir>.
🚀 Install
pnpm add verbaly @verbaly/nuxt @verbaly/vue
pnpm add -D @verbaly/compiler # the verbaly command: init, extract, check
⚡ Wire it up
1. The module, the whole setup:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@verbaly/nuxt'],
});
Locales live in your verbaly.config (created by npx verbaly init), or inline:
modules: [['@verbaly/nuxt', { locales: ['en', 'es', 'pt'] }]],
2. Write text: components use the Vue bindings as usual:
<script setup>
import { useT } from '@verbaly/vue';
const t = useT();
</script>
<template>
<h1>{{ t('x7Ka9q2f') }}</h1>
</template>
useT() is typed by your catalog: the types go to .nuxt/verbaly.d.ts, where Nuxt links them, and npx verbaly extract writes that same file. A key no catalog has fails nuxi typecheck.
3. Switching languages (client): persists the cookie the server reads:
<script setup>
import { switchLocale } from 'verbaly';
import { useVerbaly } from '@verbaly/vue';
const verbaly = useVerbaly();
</script>
<template>
<button @click="switchLocale(verbaly, 'es')">Español</button>
</template>
That's it. The module resolves the locale per request (URL → cookie → Accept-Language → fallback), awaits the catalog before render, installs the Vue plugin, and keeps <html lang> and <html dir> in sync.
📖 Options
Via the verbaly key in nuxt.config or inline module options (fully typed in nuxt.config.ts: autocomplete and typo checking). Every @verbaly/vite option passes through, plus:
| Option | What it does |
|---|---|
cookie |
Cookie read/written for the user's choice (default verbaly-locale); false = Accept-Language only. |
fallback |
Locale when nothing matches (defaults to the source locale). |
- When your URLs carry the language, the address decides it and the cookie is not consulted: on
/es/docsa visitor gets Spanish whatever they picked before, and on an unprefixed page they get your source language. That follows yourroutingsetting; nothing to configure here. - No dependency on
nuxtor@nuxt/kit: the module is typed structurally; the only moving parts are core primitives (resolveRequestLocale) and the generatedcreateRequestInstance. - For fully static sites (
nuxi generate), considerverbaly renderfor pre-translated output per locale.
📚 Docs
Full guide: verbaly-web.vercel.app/docs/frameworks/vue#nuxt
License
MIT © Aron Soto
Related Packages
Mark Nuxt app hydration with a DOM attribute for CSS, scripts, and end-to-end te...
The Nuxt 4 module for Tisilia clients: request-scoped clients, allowlisted heade...
Simple and easy to use translation manager for nuxt and nuxt-i18n that allows to...
Version History
| Version | Released | License |
|---|---|---|
| 0.75.0 | MIT | |
| 0.74.0 | MIT | |
| 0.73.0 | MIT | |
| 0.72.0 | MIT | |
| 0.71.0 | MIT | |
| 0.70.0 | MIT | |
| 0.69.1 | MIT | |
| 0.69.0 | MIT | |
| 0.68.0 | MIT | |
| 0.67.0 | MIT | |
| 0.66.0 | MIT | |
| 0.65.0 | MIT | |
| 0.64.0 | MIT | |
| 0.63.0 | MIT | |
| 0.62.0 | MIT | |
| 0.61.0 | MIT | |
| 0.60.0 | MIT | |
| 0.59.0 | MIT | |
| 0.58.0 | MIT | |
| 0.57.0 | MIT | |
| 0.56.1 | MIT | |
| 0.56.0 | MIT | |
| 0.55.0 | MIT | |
| 0.54.0 | MIT | |
| 0.53.0 | MIT | |
| 0.52.0 | MIT | |
| 0.51.0 | MIT | |
| 0.50.0 | MIT | |
| 0.49.0 | MIT | |
| 0.48.0 | MIT |
Showing the latest 30 of 60. See every release on npm