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

    Collections

    A collection is a set of content files that share the same dictionary key but each declare a different item index. Intlayer merges them into a single ordered list at build time.

    Declaring collection items

    Each file represents one item. The item field is its position in the list (1-based).

    faq.1.content.ts
    import { t, type Dictionary } from "intlayer";
    
    const dictionary = {
      key: "faq",
      item: 1,
      content: {
        question: t({ en: "What is Intlayer?", fr: "Qu'est-ce qu'Intlayer ?" }),
        answer: t({ en: "An i18n toolkit.", fr: "Une boîte à outils i18n." }),
      },
    } satisfies Dictionary;
    
    export default dictionary;
    faq.2.content.ts
    import { t, type Dictionary } from "intlayer";
    
    const dictionary = {
      key: "faq",
      item: 2,
      content: {
        question: t({ en: "Is it free?", fr: "Est-ce gratuit ?" }),
        answer: t({ en: "Yes, open-source.", fr: "Oui, open-source." }),
      },
    } satisfies Dictionary;
    
    export default dictionary;

    Consuming a collection

    All items

    FAQ.tsx
    import { useIntlayer } from "react-intlayer";export const FAQ = () => {  const items = useIntlayer("faq"); // { question: string; answer: string }[]  return (    <ul>      {items.map((item, index) => (        <li key={index}>          <strong>{item.question}</strong>          <p>{item.answer}</p>        </li>      ))}    </ul>  );};

    Single item by index

    tsx
    const faq2 = useIntlayer("faq", { item: 2 });// → { question: string; answer: string }

    Single item with explicit locale

    tsx
    const faq2Fr = useIntlayer("faq", { item: 2, locale: "fr" });

    Typical use-cases

    • FAQ lists
    • Pricing tiers
    • Carousel / slider slides
    • Step-by-step instructions