--- createdAt: 2024-03-07 updatedAt: 2025-09-30 title: Make a component multilingual (i18n library) in React and Next.js description: Learn how to declare and retrieve localised content to build a multilingual React or Next.js component with Intlayer. keywords: - i18n - component - react - multilingual - next.js - intlayer slugs: - doc - component - i18n applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4 --- # How to make a component multilingual (i18n) with Intlayer This guide shows the minimal steps to make a UI component multilingual in two common setups: - React (Vite/SPA) - Next.js (App Router) You will first declare your content, then retrieve it in your component. ## 1) Declare your content (shared for React and Next.js) Create a content declaration file near your component. This keeps translations close to where they are used and enables type safety. ```ts fileName="component.content.ts" import { t, type Dictionary } from "intlayer"; const componentContent = { key: "component-example", content: { title: t({ en: "Hello", fr: "Bonjour", es: "Hola", }), description: t({ en: "A multilingual React component", fr: "Un composant React multilingue", es: "Un componente React multilingüe", }), }, } satisfies Dictionary; export default componentContent; ``` JSON is also supported if you prefer configuration files. ```json fileName="component.content.json" { "$schema": "https://intlayer.org/schema.json", "key": "component-example", "content": { "title": { "nodeType": "translation", "translation": { "en": "Hello", "fr": "Bonjour", "es": "Hola" } }, "description": { "nodeType": "translation", "translation": { "en": "A multilingual React component", "fr": "Un composant React multilingue", "es": "Un componente React multilingüe" } } } } ``` ## 2) Retrieve your content ### Case A — React app (Vite/SPA) Default approach: use `useIntlayer` to retrieve by key. This keeps components lean and typed. ```tsx fileName="ComponentExample.tsx" import { useIntlayer } from "react-intlayer"; export function ComponentExample() { const content = useIntlayer("component-example"); return (
{content.description}
{content.description}
> ); } ``` Alternative: `useDictionary` can read an entire declared object if you prefer collocating structure at the call site. ```tsx fileName="ComponentWithDictionary.tsx" import { useDictionary } from "react-intlayer"; import componentContent from "./component.content"; export function ComponentWithDictionary() { const { title, description } = useDictionary(componentContent); return ({description}
{content.description}
> ); } ``` ```tsx fileName="app/[locale]/example/ClientComponent.tsx" "use client"; import { useIntlayer } from "next-intlayer"; export function ClientComponent() { const content = useIntlayer("component-example"); return ({content.description}