--- createdAt: 2026-06-12 updatedAt: 2026-06-12 title: Variants description: Use the variant metadata field in Intlayer content files to declare named content alternatives — A/B tests, seasonal banners, feature-flagged copy — and switch between them at runtime without code changes. keywords: - Variants - A/B Testing - Feature Flags - Dynamic Content - Intlayer - Internationalization slugs: - doc - concept - variants history: - version: 9.0.0 date: 2026-06-12 changes: "Release of the variants feature" author: aymericzip --- # Variants A **variant** is a set of content files that share the same dictionary `key` but each carry a different `variant` name. Intlayer serves the appropriate file based on the selector passed to `useIntlayer`. ## Declaring variants Each file represents one named alternative. Omitting `variant` (or setting it to `"default"`) marks it as the fallback. ```ts fileName="hero-banner.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { t, type Dictionary } from "intlayer"; const dictionary = { key: "hero-banner", variant: "default", content: { headline: t({ en: "Build faster with Intlayer", fr: "Développez plus vite avec Intlayer", }), cta: t({ en: "Get started", fr: "Commencer" }), }, } satisfies Dictionary; export default dictionary; ``` ```ts fileName="hero-banner.black-friday.content.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { t, type Dictionary } from "intlayer"; const dictionary = { key: "hero-banner", variant: "black_friday", content: { headline: t({ en: "50 % off — today only", fr: "−50 % — aujourd'hui seulement", }), cta: t({ en: "Shop now", fr: "Acheter maintenant" }), }, } satisfies Dictionary; export default dictionary; ``` ## Consuming variants ### Default variant ```tsx fileName="Hero.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { useIntlayer } from "react-intlayer"; export const Hero = () => { const { headline, cta } = useIntlayer("hero-banner"); // → default variant return (

{headline}

{cta}
); }; ```
```tsx fileName="Hero.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { useIntlayer } from "next-intlayer"; export const Hero = () => { const { headline, cta } = useIntlayer("hero-banner"); // → default variant return (

{headline}

{cta}
); }; ```
```vue fileName="Hero.vue" contentDeclarationFormat={["typescript", "esm", "commonjs"]} ``` ```svelte fileName="Hero.svelte" contentDeclarationFormat={["typescript", "esm", "commonjs"]}

{$content.headline}

{$content.cta}
```
```tsx fileName="Hero.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { useIntlayer } from "preact-intlayer"; export const Hero = () => { const { headline, cta } = useIntlayer("hero-banner"); // → default variant return (

{headline}

{cta}
); }; ```
```tsx fileName="Hero.tsx" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { useIntlayer } from "solid-intlayer"; export const Hero = () => { const content = useIntlayer("hero-banner"); // → default variant return (

{content().headline}

{content().cta}
); }; ```
```typescript fileName="hero.component.ts" contentDeclarationFormat={["typescript", "esm", "commonjs"]} import { Component } from "@angular/core"; import { useIntlayer } from "angular-intlayer"; @Component({ selector: "app-hero", template: `

{{ content().headline }}

{{ content().cta }}
`, }) export class HeroComponent { content = useIntlayer("hero-banner"); } ```
```javascript fileName="hero.js" import { useIntlayer } from "vanilla-intlayer"; const { headline, cta } = useIntlayer("hero-banner"); document.body.innerHTML = `

${headline}

${cta}
`; ```
### Named variant ```tsx const { headline, cta } = useIntlayer("hero-banner", { variant: "black_friday", }); ``` ### Named variant with explicit locale ```tsx const content = useIntlayer("hero-banner", { variant: "black_friday", locale: "fr", }); ``` ## Typical use-cases - A/B copy tests driven by an experiment key - Seasonal or promotional banners - Feature-flagged messaging - Locale-specific marketing campaigns