Author:
    Creation:2026-06-12Last update:2026-06-26

    Dynamic Dictionaries

    Intlayer supports two mechanisms for expressing content that goes beyond a single static dictionary per key. Each is declared through a top-level metadata field in the content file; no wrapper function is needed.

    Feature Metadata field Selector in useIntlayer
    Collections item: N { item: N }
    Variants variant: "name" or variant: { … } { variant: "name" } or { variant: { … } }

    Both compose with the locale argument and support selective / lazy loading via importMode.

    When to use which

    • Collections — ordered list of items managed in separate files (FAQ entries, blog posts, products).
    • Variants — named or structured content alternatives:
      • a string variant for A/B tests, seasonal banners, or feature flags;
      • an object variant for CMS records, user-specific copy, or any content addressed by a set of fields (the former "dynamic records").
    Earlier versions exposed a separate meta field for record-keyed content. It has been merged into variant: pass an object to variant instead of using meta.

    Selector disambiguation

    A key may declare both dimensions at once (e.g. a collection whose items each have a variant). They are resolved in the order:

    plaintext
    variant → item

    So { variant: "promo" } on a variant × item key returns every promo item as an array, and adding { item: 2 } narrows it to a single entry.