---
createdAt: 2025-04-18
updatedAt: 2026-09-27
priority: 9
title: "Vite + Vue i18n - Complete guide to translate your app"
description: "Set up Intlayer in a Vite and Vue app: typed per-component content with composables, a locale switcher and localized routes."
keywords:
- Internationalization
- Documentation
- Intlayer
- Vite
- Vue
- JavaScript
slugs:
- doc
- environment
- vite-and-vue
applicationTemplate: https://github.com/aymericzip/intlayer-vite-vue-template
applicationShowcase: https://intlayer-vite-vue-template.vercel.app
youtubeVideo: https://www.youtube.com/watch?v=IE3XWkZ6a5U
history:
- version: 8.9.0
date: 2026-05-04
changes: "Update Solid useIntlayer API usage to direct property access"
- version: 8.5.0
date: 2026-03-24
changes: Change installIntlayer by use(intlayer)
- version: 7.5.9
date: 2025-12-30
changes: "Add init command"
- version: 5.5.10
date: 2025-06-29
changes: "Initial history"
author: aymericzip
---
# Translate your Vite and Vue website using Intlayer
## Table of Contents
## Why Intlayer over alternatives?
Compared to main solutions like `vue-i18n` or `i18next`, Intlayer is a solution that comes with integrated optimizations such as:
Intlayer is optimized to work perfectly with Vue by offering **component-level content scoping**, **reactive translations**, and all the features needed for scaling internationalization (i18n).
Instead of loading massive JSON files into your pages, load only the necessary content. Intlayer helps **reduce your bundle and page sizes by up to 50%**.
Scoping your application's content **facilitates maintenance** for large-scale applications. You can duplicate or delete a single feature folder without the mental burden of reviewing your entire content codebase. Additionally, Intlayer is **fully typed** to ensure your content's accuracy.
Co-locating content **reduces the context needed** by Large Language Models (LLMs). Intlayer also comes with a suite of tools, such as a **CLI** to test for missing translations,**[LSP](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/lsp.md)**, **[MCP](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md)**, and **[agent skills](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/agent_skills.md)**, to make the developer experience (DX) even smoother for AI agents.
- [LSP](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/lsp.md)
- [MCP](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md)
- [agent skills](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/agent_skills.md)
Use automation to translate in your CI/CD pipeline using the LLM of your choice at the cost of your AI provider. Intlayer also offers a **compiler** to automate content extraction, as well as a [web platform](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md) to help **translate in the background**.
- [web platform](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md)
Connecting massive JSON files to components can lead to performance and reactivity issues. Intlayer optimizes your content loading at build time.
More than just an i18n solution, Intlayer provides an **self-hosted [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md)** and a **[full CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md)** to help you manage your multilingual content in **real-time**, making collaboration with translators, copywriters, and other team members seamless. Content can be stored locally and/or remotely.
- [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md)
- [full CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md)
## Step-by-Step Guide to Set Up Intlayer in a Vite and Vue Application
See [Application Template](https://github.com/aymericzip/intlayer-vite-vue-template) on GitHub.
Install the necessary packages using npm:
```bash packageManager="npm"
npx intlayer init --interactive
```
```bash packageManager="pnpm"
pnpm dlx intlayer init --interactive
```
```bash packageManager="yarn"
yarn dlx intlayer init --interactive
```
```bash packageManager="bun"
bunx intlayer init --interactive
```
> the `--interactive` flag is optional. Use `intlayer-cli init` if you're an AI agent.
> This command will detect your environment and install the required packages. For example:
```bash packageManager="npm"
npm install intlayer vue-intlayer
npm install vite-intlayer --save-dev
```
```bash packageManager="pnpm"
pnpm add intlayer vue-intlayer
pnpm add vite-intlayer --save-dev
```
```bash packageManager="yarn"
yarn add intlayer vue-intlayer
yarn add vite-intlayer --save-dev
```
```bash packageManager="bun"
bun add intlayer vue-intlayer
bun add vite-intlayer --dev
```
- **intlayer**
The core package that provides internationalization tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/index.md).
- **vue-intlayer**
The package that integrates Intlayer with Vue application. It provides context providers and composables for Vue internationalization.
- **vite-intlayer**
Includes the Vite plugin for integrating Intlayer with the [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), as well as middleware for detecting the user's preferred locale, managing cookies, and handling URL redirection.
### Architecture
In this architecture, `vue-intlayer` provides the plugin installed in `main.ts`. Vue components declare and consume translations locally using composables, with Vite hot reloading handled by `vite-intlayer`.
```bash
.
├── src
│ ├── app.content.ts
│ ├── App.vue # Root component
│ ├── components
│ │ ├── helloWorld
│ │ │ ├── helloWorld.content.ts
│ │ │ └── HelloWorld.vue
│ │ └── LocaleSwitcher.vue
│ ├── main.ts # Entry point installing vue-intlayer plugin
│ └── style.css
├── index.html
├── intlayer.config.ts
├── package.json
├── tsconfig.json
└── vite.config.ts
```
### Configuration
Create a config file to configure the languages of your application:
```typescript fileName="intlayer.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
import { Locales, type IntlayerConfig } from "intlayer";
const config: IntlayerConfig = {
internationalization: {
locales: [
Locales.ENGLISH,
Locales.FRENCH,
Locales.SPANISH,
// Your other locales
],
defaultLocale: Locales.ENGLISH,
},
};
export default config;
```
> Through this configuration file, you can set up localized URLs, middleware redirection, cookie names, the location and extension of your content declarations, disable Intlayer logs in the console, and more. For a complete list of available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md).
- [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md)
Add the intlayer plugin into your configuration.
```typescript fileName="vite.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { intlayer } from "vite-intlayer";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), intlayer()],
});
```
> The `intlayer()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimize performance.
Create and manage your content declarations to store translations:
```tsx fileName="src/helloWorld.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]}
import { t, type Dictionary } from "intlayer";
const helloWorldContent = {
key: "helloworld",
content: {
count: t({ en: "count is ", fr: "le compte est ", es: "el recuento es " }),
edit: t({
en: "Edit components/HelloWorld.vue and save to test HMR",
fr: "Éditez components/HelloWorld.vue et enregistrez pour tester HMR",
es: "Edita components/HelloWorld.vue y guarda para probar HMR",
}),
checkOut: t({ en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
officialStarter: t({
en: ", the official Vue + Vite starter",
fr: ", le starter officiel Vue + Vite",
es: ", el starter oficial Vue + Vite",
}),
learnMore: t({
en: "Learn more about IDE Support for Vue in the ",
fr: "En savoir plus sur le support IDE pour Vue dans le ",
es: "Aprenda más sobre el soporte IDE para Vue en el ",
}),
vueDocs: t({
en: "Vue Docs Scaling up Guide",
fr: "Vue Docs Scaling up Guide",
es: "Vue Docs Scaling up Guide",
}),
readTheDocs: t({
en: "Click on the Vite and Vue logos to learn more",
fr: "Cliquez sur les logos Vite et Vue pour en savoir plus",
es: "Haga clic en los logotipos de Vite y Vue para obtener más información",
}),
},
} satisfies Dictionary;
export default helloWorldContent;
```
```json fileName="src/helloWorld.content.json" contentDeclarationFormat="json"
{
"$schema": "https://intlayer.org/schema.json",
"key": "helloworld",
"content": {
"count": {
"nodeType": "translation",
"translation": {
"en": "count is ",
"fr": "le compte est ",
"es": "el recuento es "
}
},
"edit": {
"nodeType": "translation",
"translation": {
"en": "Edit components/HelloWorld.vue and save to test HMR",
"fr": "Éditez components/HelloWorld.vue et enregistrez pour tester HMR",
"es": "Edita components/HelloWorld.vue y guarda para probar HMR"
}
},
"checkOut": {
"nodeType": "translation",
"translation": {
"en": "Check out ",
"fr": "Vérifiez ",
"es": "Compruebe "
}
},
"officialStarter": {
"nodeType": "translation",
"translation": {
"en": "the official Vue + Vite starter",
"fr": "le starter officiel Vue + Vite",
"es": "el starter oficial Vue + Vite"
}
},
"learnMore": {
"nodeType": "translation",
"translation": {
"en": "Learn more about IDE Support for Vue in the ",
"fr": "En savoir plus sur le support IDE pour Vue dans le ",
"es": "Aprenda más sobre el soporte IDE para Vue en el "
}
},
"vueDocs": {
"nodeType": "translation",
"translation": {
"en": "Vue Docs Scaling up Guide",
"fr": "Vue Docs Scaling up Guide",
"es": "Vue Docs Scaling up Guide"
}
},
"readTheDocs": {
"nodeType": "translation",
"translation": {
"en": "Click on the Vite and Vue logos to learn more",
"fr": "Cliquez sur les logos Vite et Vue pour en savoir plus",
"es": "Haga clic en los logotipos de Vite y Vue para obtener más información"
}
}
}
}
```
> Your content declarations can be defined anywhere in your application as soon they are included into the `contentDir` directory (by default, `./src`). And match the content declaration file extension (by default, `.content.{json,ts,tsx,js,jsx,mjs,cjs,md,mdx,yaml,yml}`).
> For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
- [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md)
To utilize Intlayer's internationalization features throughout your Vue application, you first need to register the Intlayer singleton instance in your main file. This step is crucial as it provides the internationalization context to all components in your application, making translations accessible anywhere in your component tree.
```javascript fileName=main.js
import { createApp } from "vue";
import { intlayer } from "vue-intlayer";
import App from "./App.vue";
import "./style.css";
const app = createApp(App);
// Inject the provider at the top level
app.use(intlayer);
// Mount the app
app.mount("#app");
```
> You can also call `installIntlayer(app)` directly as a function if you prefer:
>
> ```javascript
> import { intlayer } from "vue-intlayer";
> app.use(intlayer);
> ```
Access your content dictionaries throughout your application by creating a main Vue component and using the `useIntlayer` composables:
```vue fileName="src/HelloWord.vue"
```
> If your app already exists, you can use the [Intlayer Compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md), as well as the [extract command](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md), to transform thousands of components in a second.
- [Intlayer Compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md)
- [extract command](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md)
#### Accessing Content in Intlayer
Intlayer offers different APIs to access your content:
- **Component-based syntax** (recommended):
Use the ``, or `` syntax to render content as an Intlayer Node. You can also customize the rendering by using the `.use()` method: ``. This integrates seamlessly with the [Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) and [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md).
- **String-based syntax**:
Use `{{ myContent }}` to render the content as plain text, without Visual Editor support.
- **Raw HTML syntax**:
Use `` to render the content as raw HTML, without Visual Editor support.
- **Destructuration syntax**:
The `useIntlayer` composable returns an Proxy with the content. This proxy can be destructured to access the content while keeping the reactivity.
- Use `const content = useIntlayer("myContent");` And `{{ content.myContent }}` / ``.
- Or use `const { myContent } = useIntlayer("myContent");` And `{{ myContent}}` / `` to destructure the content.
To change the language of your content, you can use the `setLocale` function provided by the `useLocale` composable. This function allows you to set the locale of the application and update the content accordingly.
Create a component to switch between languages:
```vue fileName="src/components/LocaleSwitcher.vue"
```
Then, use this component in your App.vue:
```vue fileName="src/App.vue"
```
Adding localized routing in a Vue application typically involves using Vue Router with locale prefixes. This makes unique routes for each language, which is useful for SEO and SEO-friendly URLs.
Example:
```plaintext
- https://example.com/about
- https://example.com/es/about
- https://example.com/fr/about
```
First, install Vue Router:
```bash packageManager="npm"
npm install vue-router
npx intlayer init
```
```bash packageManager="pnpm"
pnpm add vue-router
pnpm intlayer init
```
```bash packageManager="yarn"
yarn add vue-router
```
Then, create a router configuration that handles locale-based routing:
```js fileName="src/router/index.ts"
import {
localeFlatMap,
type Locale,
} from 'intlayer';
import { createIntlayerClient } from "vue-intlayer";
import { createRouter, createWebHistory } from 'vue-router';
import HomeView from './views/home/HomeView.vue';
import RootView from './views/root/Root.vue';
/**
* Declare the routes with locale-specific paths and metadata.
*/
const routes = localeFlatMap(({ urlPrefix, locale }) => [
{
path: `${urlPrefix}/`,
name: `Root-${locale}`,
component: RootView,
meta: {
locale,
},
},
{
path: `${urlPrefix}/home`,
name: `Home-${locale}`,
component: HomeView,
meta: {
locale,
},
},
]);
// Create the router instance
export const router = createRouter({
history: createWebHistory(),
routes,
});
// Add navigation guard for locale handling
router.beforeEach((to, _from, next) => {
const client = createIntlayerClient();
const metaLocale = to.meta.locale as Locale;
// Reuse the locale defined in the route meta
client.setLocale(metaLocale);
next();
});
```
> The name is used to identify the route in the router. It should be unique across all routes to avoid conflicts and ensure proper navigation and linking.
Then, register the router in your main.js file:
```js fileName="src/main.ts"
import { createApp } from "vue";
import App from "./App.vue";
import { router } from "./router";
import "./style.css";
const app = createApp(App);
// Add the router to the app
app.use(router);
// Mount the app
app.mount("#app");
```
Then update your `App.vue` file to render the RouterView component. This component will display the matched component for the current route.
```vue fileName="src/App.vue"
```
In parallel, you can also use the `intlayerProxy` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
> Note that to use the `intlayerProxy` in production, you need to switch the `vite-intlayer` package from `devDependencies` to `dependencies`.
> Since Intlayer v9, `intlayerProxy()` is bundled directly into the `intlayer()` plugin and enabled by default through the `routing.enableProxy` option (`true` by default). Registering it separately as shown below is now optional. It is kept for backward compatibility and for setups that need to control plugin order. Set `routing.enableProxy: false` to opt out. See the [v9 release notes](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/releases/v9.md).
- [v9 release notes](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/releases/v9.md)
```typescript {3,7} fileName="vite.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { intlayer } from "vite-intlayer";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
intlayer({
proxy: {
ignore: (req) => req.url?.startsWith("/api"),
},
}),
],
});
```
To automatically update the URL when the user changes the language, you can modify the `LocaleSwitcher` component to use Vue Router:
```vue fileName="src/components/LocaleSwitcher.vue"
```
When your application supports multiple languages, it's crucial to update the `` tag's `lang` and `dir` attributes to match the current locale. Doing so ensures:
- **Accessibility**: Screen readers and assistive technologies rely on the correct `lang` attribute to pronounce and interpret content accurately.
- **Text Rendering**: The `dir` (direction) attribute ensures that text is rendered in the proper order (e.g., left-to-right for English, right-to-left for Arabic or Hebrew), which is essential for readability.
- **SEO**: Search engines use the `lang` attribute to determine the language of your page, helping to serve the right localized content in search results.
By updating these attributes dynamically when the locale changes, you guarantee a consistent and accessible experience for users across all supported languages.
```js fileName="src/composables/useI18nHTMLAttributes.ts"
import { watch } from "vue";
import { useLocale } from "vue-intlayer";
import { getHTMLTextDir } from "intlayer";
/**
* Composable that updates the HTML element's `lang` and `dir` attributes
* based on the current locale.
*
* @example
* // In your App.vue or a global component
* import { useI18nHTMLAttributes } from './composables/useI18nHTMLAttributes'
*
* useI18nHTMLAttributes()
*/
export const useI18nHTMLAttributes = () => {
const { locale } = useLocale();
// Update the HTML attributes whenever the locale changes
watch(
() => locale.value,
(newLocale) => {
if (!newLocale) return;
// Update the language attribute
document.documentElement.lang = newLocale;
// Set the text direction (ltr for most languages, rtl for Arabic, Hebrew, etc.)
document.documentElement.dir = getHTMLTextDir(newLocale);
},
{ immediate: true }
);
};
```
Use this composable in your `App.vue` or a global component:
```vue fileName="src/App.vue"
```
To ensure that your application’s navigation respects the current locale, you can create a custom `Link` component. This component automatically prefixes internal URLs with the current language, so that. For example, when a French-speaking user clicks on a link to the "About" page, they are redirected to `/fr/about` instead of `/about`.
This behavior is useful for several reasons:
- **SEO and User Experience**: Localized URLs help search engines index language-specific pages correctly and provide users with content in their preferred language.
- **Consistency**: By using a localized link throughout your application, you guarantee that navigation stays within the current locale, preventing unexpected language switches.
- **Maintainability**: Centralizing the localization logic in a single component simplifies the management of URLs, making your codebase easier to maintain and extend as your application grows.
```vue fileName="src/components/Link.vue"
```
For use with Vue Router, create a router-specific version:
```vue fileName="src/components/RouterLink.vue"
```
Use these components in your application:
```vue fileName="src/App.vue"
RootHome
Root
Home
```
If you have an existing codebase, transforming thousands of files can be time-consuming.
To ease this process, Intlayer propose a [compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md) / [extractor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md) to transform your components and extract the content.
- [compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md)
- [extractor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md)
To set it up, you can add a `compiler` section in your `intlayer.config.ts` file:
```typescript fileName="intlayer.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
import { type IntlayerConfig } from "intlayer";
const config: IntlayerConfig = {
// ... Rest of your config
compiler: {
/**
* Indicates if the compiler should be enabled.
*/
enabled: true,
/**
* Defines the output files path
*/
output: ({ fileName, extension }) => `./${fileName}${extension}`,
/**
* Indicates if the components should be saved after being transformed.
*
* - If `true`, the compiler will rewrite the component file in the disk. So the transformation will be permanent, and the compiler will skip the transformation for the next process. That way, the compiler can transform the app, and then it can be removed.
*
* - If `false`, the compiler will inject the `useIntlayer()` function call into the code in the build output only, and keep the base codebase intact. The transformation will be done only in memory.
*/
saveComponents: false,
/**
* Dictionary key prefix
*/
dictionaryKeyPrefix: "",
},
};
export default config;
```
Run the extractor to transform your components and extract the content
```bash packageManager="npm"
npx intlayer extract
```
```bash packageManager="pnpm"
pnpm intlayer extract
```
```bash packageManager="yarn"
yarn intlayer extract
```
```bash packageManager="bun"
bun x intlayer extract
```
> Since v9, the `intlayerCompiler` is included in the `intlayer` plugin. So you don't need to add it manually.
Update your `vite.config.ts` to include the `intlayerCompiler` plugin:
```ts fileName="vite.config.ts"
import { defineConfig } from "vite";
import { intlayer, intlayerCompiler } from "vite-intlayer";
export default defineConfig({
plugins: [
intlayer(),
intlayerCompiler(), // Adds the compiler plugin
],
});
```
Build your application to transform your components and extract the content
```bash packageManager="npm"
npm run build # Or npm run dev
```
```bash packageManager="pnpm"
pnpm run build # Or pnpm run dev
```
```bash packageManager="yarn"
yarn build # Or yarn dev
```
```bash packageManager="bun"
bun run build # Or bun run dev
```
### (Optional) Sitemap and robots.txt (build-time)
Intlayer includes formatters such as `generateSitemap` and `getMultilingualUrls` that produce crawler-ready multilingual `sitemap.xml` and `robots.txt` output you can write into your project’s `public/` folder. In practice you run a small Node script **before** Vite (for example `predev` / `prebuild` npm hooks) so those files exist when you build or serve the app.
#### Sitemap
Intlayer’s sitemap generator respects your locale setup and includes the usual metadata for crawlers.
> The generated sitemap supports the `xhtml:link` namespace (hreflang XML extensions). Unlike basic generators that only emit flat URLs, Intlayer wires bidirectional links between every localized variant of each page (for example `/about`, `/fr/about`, or `/about?lang=fr`, depending on your routing mode), which helps search engines relate localized URLs.
#### Robots.txt
Use `getMultilingualUrls` so `Disallow` entries cover every localized spelling of sensitive paths.
#### 1. Add `generate-seo.mjs` at the project root
```javascript fileName="generate-seo.mjs"
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { generateSitemap, getMultilingualUrls } from "intlayer";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const SITE_URL = (process.env.SITE_URL || "http://localhost:5173").replace(
/\/$/,
""
);
const pathList = [
{ path: "/", changefreq: "daily", priority: 1.0 },
{ path: "/about", changefreq: "monthly", priority: 0.7 },
];
const sitemapXml = generateSitemap(pathList, {
siteUrl: "https://example.com",
});
fs.writeFileSync(path.join(__dirname, "public", "sitemap.xml"), sitemapXml);
const getAllMultilingualUrls = (urls) =>
urls.flatMap((url) => Object.values(getMultilingualUrls(url)));
const disallowedPaths = getAllMultilingualUrls(["/admin", "/private"]);
const robotsTxt = [
"User-agent: *",
"Allow: /",
...disallowedPaths.map((path) => `Disallow: ${path}`),
"",
`Sitemap: https://example.com/sitemap.xml`,
].join("\n");
fs.writeFileSync(path.join(__dirname, "public", "robots.txt"), robotsTxt);
console.log("SEO files generated successfully.");
```
`intlayer` must be installed so the script can import it. Set `SITE_URL` in the environment for production (for example in CI).
> Prefer `generate-seo.mjs` for Node ESM. If you use `generate-seo.js` instead, ensure `"type": "module"` is set in `package.json`, or run Node with ESM enabled.
#### 2. Run the script before Vite
```json fileName="package.json"
{
"scripts": {
"dev": "vite",
"prebuild": "node generate-seo.mjs",
"build": "vite build",
"preview": "vite preview"
}
}
```
Adjust if you use pnpm or yarn. You can also invoke the same script from CI or another step if that fits your workflow.
### Configure TypeScript
Intlayer uses module augmentation to get benefits of TypeScript and make your codebase stronger.


Ensure your TypeScript configuration includes the autogenerated types.
```json5 fileName="tsconfig.json"
{
// ... Your existing TypeScript configurations
"include": [
// ... Your existing TypeScript configurations
".intlayer/**/*.ts", // Include the auto-generated types
],
}
```
### Git Configuration
It is recommended to ignore the files generated by Intlayer. This allows you to avoid committing them to your Git repository.
To do this, you can add the following instructions to your `.gitignore` file:
```bash
# Ignore the files generated by Intlayer
.intlayer
```
### VS Code Extension
To improve your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
- [Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
This extension provides:
- **Autocompletion** for translation keys.
- **Real-time error detection** for missing translations.
- **Inline previews** of translated content.
- **Quick actions** to easily create and update translations.
For more details on how to use the extension, refer to the [Intlayer VS Code Extension documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/vs_code_extension.md).
- [Intlayer VS Code Extension documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/vs_code_extension.md)
### Vue Devtools
`vue-intlayer` registers an **Intlayer** panel in [Vue Devtools](https://devtools.vuejs.org/) out of the box. Open the **Vue** tab of your browser devtools and select **Intlayer** in the sidebar to inspect your dictionaries and their per-locale translations, or to switch the current locale of the app.
When the [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) is set up, plain-text translations can also be edited inline from the panel: edits are written back to your content declaration files and hot-reloaded in the app.
### Go Further
To go further, you can implement the [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) or externalize your content using the [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md).
- [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md)
- [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md)
## Frequently Asked Questions
- **`vue-i18n`**: the reference library, with message catalogs registered globally and ICU style formatting. It has no way to namespace messages, so a page bundles every catalog and the bundle size keeps growing as the app adds pages.
- **`Intlayer`**: the most advanced solution. Content declared anywhere in your codebase ([next to each component or centralized](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/per-component_vs_centralized_i18n.md)) and compiled by the Vite plugin at build time, fully typed, with AI translation, a visual editor and a CMS.
The practical difference is scope and typing. `vue-i18n` resolves keys as strings at runtime, so a renamed key fails silently, while Intlayer generates types from your declarations and drops content no component uses. See [why Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/interest_of_intlayer.md) and the [Vue i18n benchmark](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md).
- [why Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/interest_of_intlayer.md)
- [Vue i18n benchmark](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md)
Much less than a namespace based setup, because a page never downloads a catalog it does not render. The build time compiler replaces `useIntlayer` calls with the exact dictionary entries a component uses, so unused keys and unused languages are dropped, and [dynamic dictionaries](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dynamic_dictionaries/index.md) split the rest per locale. Measured against the usual alternatives, Intlayer reduces bundle and page size by up to 50%. See [bundle optimization](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/bundle_optimization.md) and the [benchmark](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md).
- [dynamic dictionaries](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dynamic_dictionaries/index.md)
- [bundle optimization](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/bundle_optimization.md)
- [benchmark](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md)
Yes, and there are two paths. You can migrate the content progressively with the [vue-i18n migration guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/migration_from_vue-i18n_to_intlayer.md). Or you can keep your current API entirely: the [compat adapters](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compat/index.md) expose the exact same API as `vue-i18n`, but served by Intlayer dictionaries, so imports change and component code does not.
- [vue-i18n migration guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/migration_from_vue-i18n_to_intlayer.md)
- [compat adapters](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compat/index.md)
Yes. The [sync JSON plugin](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/plugins/sync-json.md) keeps your `/messages/{locale}/{namespace}.json` files as the source of truth and generates Intlayer dictionaries from them, in both directions. A [sync PO plugin](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/plugins/sync-po.md) does the same for gettext catalogs, and [per locale files](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/per_locale_file.md) let you split content by language instead of grouping locales in one file.
- [sync JSON plugin](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/plugins/sync-json.md)
- [sync PO plugin](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/plugins/sync-po.md)
- [per locale files](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/per_locale_file.md)
No. Run `npx intlayer extract` and Intlayer reads your components, pulls the user facing strings out and writes a `.content` file next to each one, so you review a diff instead of copying strings into a catalog one at a time. Step 11 of this guide walks through it.
For a fully automated pipeline, the [Intlayer Compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md) does the same at build time: it scans your JSX, TSX, Vue and Svelte source on every change, generates the dictionaries and keeps them in sync through hot module replacement, so there are no keys to maintain by hand at all.
- [Intlayer Compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md)
Two limits are worth knowing before you turn the compiler on. It works by static analysis, so strings that only exist at runtime, such as API error codes or CMS fields, stay out of reach. And it has to tell user facing text apart from application logic like `className="active"` or a status code, which needs a few annotations in a large codebase. The [extract command](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md) avoids both by keeping you in the loop.
- [extract command](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md)
Five pieces, all optional:
- **[VS Code extension](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/vs_code_extension.md)**: jump from a `useIntlayer` key to the content file that declares it, extract content from a component, and run build, fill, test, push and pull from the command palette or a dedicated Intlayer tab.
- **[LSP server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/lsp.md)**: the same awareness in any editor that speaks LSP, with go to definition, find all references, hover previews of a translated value, autocompletion of keys and fields, and a warning when a key is not declared anywhere. It also resolves `i18next`, `react-i18next`, `next-intl` and `use-intl` calls, which helps while you migrate.
- **[MCP server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md)**: exposes the Intlayer documentation and CLI to Cursor, VS Code, Claude Desktop, Claude Code and ChatGPT, so an assistant answers from current docs instead of guessing, and can run commands such as `intlayer fill` itself.
- **[Agent skills](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/agent_skills.md)**: focused skills such as `intlayer-config`, `intlayer-cli` and `intlayer-content`, plus one per framework, that teach an agent your routing setup and the content node types.
- **[ESLint plugin](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/eslint.md)**: `no-raw-text` flags hardcoded strings, with further rules for static dictionary keys and unused content.
Yes. `useIntlayer` is a composable used inside `