HomeSandboxShowcaseAppDocBlog
    • EnglishEnglish
      EN
    • русскийRussian
      RU
    • 日本語Japanese
      JA
    • françaisFrench
      FR
    • 한국어Korean
      KO
    • 中文Chinese
      ZH
    • españolSpanish
      ES
    • DeutschGerman
      DE
    • العربيةArabic
      AR
    • italianoItalian
      IT
    • British EnglishBritish English
      EN-GB
    • portuguêsPortuguese
      PT
    • हिन्दीHindi
      HI
    • TürkçeTurkish
      TR
    • polskiPolish
      PL
    • IndonesiaIndonesian
      ID
    • Tiếng ViệtVietnamese
      VI
    • українськаUkrainian
      UK
    /
    Filter docs by framework
    Alt+←
    Why Intlayer ?
    Get Started
    Concept
    • How Intlayer Works
    • Configuration
    • TestFillBuildWatchExtractLoginPushPullConfigurationListVersionEditorLiveDebugDoc ReviewDoc TranslateSDK
    • Visual Editor
    • CMS
    • CI/CD Integration
    • TranslationPluralEnumerationConditionGenderInsertionFileNestingMarkdownHTMLFunction Fetching
    • Per Locale File
    • Compiler
    • Auto Fill
    • Testing
    • Bundle Optimization
    Environment
    • Next.js 14 and App Router
      Next.js 15
      Next.js no locale path
      Next.js and Page Router
      Compiler
    • Tanstack Start Solid
    • Astro and React
      Astro and Svelte
      Astro and Vue
      Astro and Solid
      Astro and Preact
      Astro and Lit
      Astro and Vanilla JS
    • React Router v7
      React Router v7 (fs-routes)
      Compiler
    • Nuxt and Vue
    • Vite and Solid
    • SvelteKit
    • Vite and Preact
    • Vite and Vanilla JS
    • Vite and Lit
    • Angular 19 (Webpack)
      Analog
    • React CRA
    • React Native and Expo
    • Express.js
      NestJS
      Fastify
      Hono
      Adonis
    • Lynx and React
    Plugins
    • JSON
    • gettext (.po)
    VS Code Extension
    Agent
    • MCP Server
    • Agent skills
    Releases
    • v8
    • v7
    • v6
    Benchmark
    • Next.js
    • TanStack
    • Vue
    • Solid
    • Svelte
    Blog
    Ask a question
    1. Documentation
    2. Packages
    3. Next intlayer
    4. UseIntlayer
    Creation:2025-08-23Last update:2026-05-06
    Reference this doc to your favorite AI assistant
    ChatGPT
    Claude
    DeepSeek
    Google AI mode
    Gemini
    Perplexity
    Mistral
    Grok

    Ask your question and get a summary of the document by referencing this page and the AI provider of your choice

    Version History

    1. "Update Solid useIntlayer API usage to direct property access"
      v8.9.05/4/2026
    2. "Initial history"
      v5.5.106/29/2025
    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 documentation
    Copy

    Copy doc Markdown to clipboard

    Next.js Integration: useIntlayer Hook Documentation

    The useIntlayer hook is tailored for Next.js applications to fetch and manage localized content efficiently. This documentation will focus on how to utilize the hook within Next.js projects, ensuring proper localization practices.

    Importing useIntlayer in Next.js

    Depending on whether you're working on client-side or server-side components in a Next.js application, you can import the useIntlayer hook as follows:

    • Client Component:

      typescript
      Copy code

      Copy the code to the clipboard

      import { useIntlayer } from "next-intlayer"; // Used in client-side components
    • Server Component:

      tsx
      Copy code

      Copy the code to the clipboard

      import { useIntlayer } from "next-intlayer/server"; // Used in server-side components

    Parameters

    1. key: A string identifier for the dictionary key from which you want to retrieve content.
    2. locale (optional): A specific locale to use. If omitted, the hook defaults to the locale set in the client or server context.

    Dictionary Files

    It's crucial that all content keys are defined within content declaration files to prevent runtime errors and ensure type safety. This approach also facilitates TypeScript integration for compile-time validation.

    Instructions for setting up content declaration files are available here.

    Example Usage in Next.js

    Here's how you can implement the useIntlayer hook within a Next.js page to dynamically load localized content based on the application's current locale:

    src/pages/[locale]/index.tsx
    Copy code

    Copy the code to the clipboard

    import { ClientComponentExample } from "@components/ClientComponentExample";
    import { ServerComponentExample } from "@components/ServerComponentExample";
    import { type NextPageIntlayer, IntlayerClientProvider } from "next-intlayer";
    import { useIntlayer, IntlayerServerProvider } from "next-intlayer/server";
    
    const HomePage: NextPageIntlayer = async ({ params }) => {
      const { locale } = await params;
    
      const content = useIntlayer("homepage", locale);
    
      return (
        <>
          <p>{content.introduction}</p>
          <IntlayerClientProvider locale={locale}>
            <ClientComponentExample />
          </IntlayerClientProvider>
          <IntlayerServerProvider locale={locale}>
            <ServerComponentExample />
          </IntlayerServerProvider>
        </>
      );
    };
    src/components/ClientComponentExample.tsx
    Copy code

    Copy the code to the clipboard

    "use-client";
    
    import type { FC } from "react";
    import { useIntlayer } from "next-intlayer";
    
    const ClientComponentExample: FC = () => {
      const content = useIntlayer("component-content");
    
      return (
        <div>
          <h1>{content.title}</h1>
          <p>{content.description}</p>
        </div>
      );
    };
    src/components/ServerComponentExample.tsx
    Copy code

    Copy the code to the clipboard

    import type { FC } from "react";
    import { useIntlayer } from "next-intlayer/server";
    
    const ServerComponentExample: FC = () => {
      const content = useIntlayer("component-content");
    
      return (
        <div>
          <h1>{content.title}</h1>
          <p>{content.description}</p>
        </div>
      );
    };

    Handling Attribute Localization

    To localize attributes such as alt, title, href, aria-label, etc., ensure you reference the content correctly:

    tsx
    Copy code

    Copy the code to the clipboard

    <img src={content.image.src.value} alt={content.image.alt.value} /><img src={content.image.src.toString()} alt={content.image.alt.toString()} /><img src={String(content.image.src)} alt={String(content.image.alt)} />

    Further Information

    • Intlayer Visual Editor: Learn how to use the visual editor for easier content management here.

    This documentation outlines the use of the useIntlayer hook specifically within Next.js environments, providing a robust solution for managing localization across your Next.js applications.

    Why Intlayer ?
    Alt+→

    In this page

      Discussions are anonymous and regularly reviewed to address common issues. Feel free to share feature ideas, feedback on the documentation, or anything related to Intlayer, we use this input to shape our roadmap and improve the product.

      import { useIntlayer } from "next-intlayer"; // Used in client-side components
      import { useIntlayer } from "next-intlayer/server"; // Used in server-side components
      <img src={content.image.src.value} alt={content.image.alt.value} /><img src={content.image.src.toString()} alt={content.image.alt.toString()} /><img src={String(content.image.src)} alt={String(content.image.alt)} />