Creation:2026-06-12Last update:2026-06-12
Reference this doc to your favorite AI assistantChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Release of the collection dictionaries feature"v9.0.06/12/2026
Edit this doc
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
Copy doc Markdown to clipboard
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
Copy code
Copy the code to the clipboard
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
Copy code
Copy the code to the clipboard
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
Copy code
Copy the code to the clipboard
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
Copy code
Copy the code to the clipboard
const faq2 = useIntlayer("faq", { item: 2 });// → { question: string; answer: string }Single item with explicit locale
tsx
Copy code
Copy the code to the clipboard
const faq2Fr = useIntlayer("faq", { item: 2, locale: "fr" });Typical use-cases
- FAQ lists
- Pricing tiers
- Carousel / slider slides
- Step-by-step instructions