Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
New Intlayer v9 - What's new?
Welcome to Intlayer v9! This major release marks a huge milestone in simplifying the migration path to Intlayer with Compat Adapter Packages for major i18n libraries (react-i18next, next-intl, vue-i18n, etc.) and adds support for rich content structures: Collections, Variants, and Dynamic Records.
Table of contents
Compat Adapter Packages
Migrating to Intlayer from popular i18n libraries is now easier than ever. We have created five compat packages that expose the exact same public APIs as standard i18n libraries but delegate all translation work to Intlayer at runtime.
Expose Same Public API with Strict Typing
By replacing imports, you get all the benefits of Intlayer (including compile-time type safety against your actual dictionaries) with minimal code changes:
@intlayer/i18next@intlayer/react-i18next@intlayer/next-intl@intlayer/next-i18next@intlayer/vue-i18n
For example, simply change:
Copy the code to the clipboard
to:
Copy the code to the clipboard
Your keys will now be strictly typed against your Intlayer dictionaries, offering full dot-path auto-completion in your IDE!
Bundler Alias Plugins (Vite, Next.js, Turbopack)
To allow migrating without rewriting all your import statements manually, each compat adapter package includes a custom bundler plugin (Vite or Next.js) under the /plugin subpath.
These plugins automatically rewrite existing imports (e.g. react-i18next or next-intl) to their @intlayer/* equivalents at build time.
Next.js (Webpack / Turbopack) Example
Instead of withIntlayer, wrap your Next.js configuration with the compat plugin:
Copy the code to the clipboard
Vite (React, Vue, Solid, Svelte) Example
Copy the code to the clipboard
Mutualized Runtime Resolver
All compat adapters now route translation resolution through a single, highly optimized runtime parser: @intlayer/core/messageFormat.
- Interpolate Message: Resolves standard
{{var}}(whitespace & dot-paths), ICU formatted args ({v, number, percent}etc.), and bare{var}templates. - Message Node Resolver: Resolves nested nodes:
insert(),plural()(CLDR plural rules),enu()(enumeration),gender(), HTML tags, arrays, and callable function nodes. - Tokenized Tag Parser: Supports inline XML/HTML tags and numbered tags (e.g.,
<1>children</1>) to power rich-text rendering out of the box.
Feature Spec: Collections, Variants & Dynamic Records
Intlayer v9 expands beyond static key-value objects, allowing dictionaries to declare dynamic layout structures that are fully typed end-to-end.
1. Collections
Define a CMS-managed list of ordered items (e.g. FAQs, products, or blog lists):
Copy the code to the clipboard
Usage:
Copy the code to the clipboard
2. Variants
Deliver A/B tests, seasonal headers, feature flags, or custom landing pages:
Copy the code to the clipboard
Usage:
Copy the code to the clipboard
3. Dynamic Records
Define dictionaries whose entries are loaded dynamically at runtime via query IDs:
Copy the code to the clipboard
Usage:
Copy the code to the clipboard
Dynamic Loading & Bundle Size Optimizations
To keep bundles extremely small, Intlayer v9 supports dynamic lazy loading.
In your configuration, set importMode to 'dynamic' or 'fetch':
Copy the code to the clipboard
At build time, @intlayer/swc and @intlayer/babel scan your files and replace useIntlayer / getIntlayer calls with tree-shakeable wrappers (useDictionary / useDictionaryDynamic). Only the content required for the selected collection item, variant, or locale is loaded, preventing your production bundle from containing unused translations.
Migration notes from v8
If you are upgrading from v8, note that the v9 does not include breaking changes. But here are the key changes:
- Locales & Dialects: If using external i18n dependencies, add their respective compat adapter plugins in your configuration or bundler setup to automatically rewrite imports.
- Custom Selectors: When calling
useIntlayer, the second parameter is now reserved for an option object containing{ locale, item, variant, id }. If you previously passed a locale string directly, you can still do so, but using the options object is recommended for advanced selections.