Author:
    Creation:2026-01-21Last update:2026-08-22

    react-intlayer Package

    The react-intlayer package provides the necessary tools to integrate Intlayer into React applications. It includes context providers, hooks, and components for handling multilingual content.

    Installation

    bash
    npm install react-intlayer
    

    Exports

    Providers

    Import:

    tsx
    import "react-intlayer";
    
    ComponentDescriptionRelated Doc
    IntlayerProviderThe main provider that wraps your application and provides the Intlayer context. Includes editor support by default.IntlayerProvider
    IntlayerProviderContentA provider component focused on content without the editor features. Use this when you don't need the visual editor.-
    HTMLProviderProvider for HTML-related internationalization settings. Allows component overrides for HTML tags.-

    Hooks

    Import:

    tsx
    import "react-intlayer";
    
    HookDescriptionRelated Doc
    useHTMLRendererHook to get a pre-configured HTML renderer function.-
    useMarkdownRendererHook to get a pre-configured Markdown renderer function.-
    useIntlayerClient-side hook that picks one dictionary by its key and returns its content. Uses the locale from context if not provided.useIntlayer
    useDictionaryHook that transforms a dictionary object and returns the content for the current locale. Processes t() translations, enumerations, etc.useDictionary
    useDictionaryAsyncHook that handles asynchronous dictionaries. Accepts a promise-based dictionary map and resolves it for the current locale.-
    useDictionaryDynamicHook that handles dynamic dictionaries loaded by key. Uses React Suspense internally for loading states.-
    useLocaleClient-side hook to get the current locale, default locale, available locales, and a function to update the locale.useLocale
    useLocaleBaseHook to get the current locale and all related fields (locale, defaultLocale, availableLocales, setLocale) from context.-
    usePathnameHook that returns the current pathname with the locale segment removed. Reactive to browser navigation via popstate.usePathname
    useRewriteURLClient-side hook to manage URL rewrites. If a rewrite rule exists for the current pathname and locale, it will update the URL.useRewriteURL
    useI18nHook that provides a translation function t() for accessing nested content by key. Mimics i18next/next-intl pattern.useI18n
    useIntlHook that provides a locale-bound Intl object. Automatically injects the current locale and uses optimized caching.-
    useLocaleStorageHook that provides locale persistence in local storage or cookies. Returns getter and setter functions.-
    useLocaleCookieDeprecated. Use useLocaleStorage instead. Hook that manages locale persistence in cookies.-
    useLoadDynamicHook to load dynamic dictionaries using React Suspense. Accepts a key and promise, caches results.-
    useIntlayerContextHook that provides the current Intlayer client context values (locale, setLocale, etc.).-
    useHTMLContextHook to access HTML component overrides from HTMLProvider context.-

    Functions

    Import:

    tsx
    import "react-intlayer";
    
    FunctionDescriptionRelated Doc
    renderHTMLStandalone utility for rendering HTML outside of components.-
    renderMarkdownStandalone utility for rendering Markdown outside of components.-
    tClient-side translation function that returns the translation of the provided multilang content. Uses context locale if not provided.translation
    getDictionaryProcesses dictionary objects and returns content for the specified locale. Processes t() translations, enumerations, markdown, HTML, etc.-
    getIntlayerRetrieves a dictionary by its key from the generated declaration and returns its content for the specified locale. Optimized version of getDictionary.-
    setLocaleInStorageSets the locale in storage (local storage or cookie based on configuration).-
    setLocaleCookieDeprecated. Use setLocaleInStorage instead. Sets the locale in a cookie.-
    localeInStorageGets the locale from storage (local storage or cookie).-
    localeCookieDeprecated. Use localeInStorage instead. Gets the locale from cookie.-

    Components

    Import:

    tsx
    import "react-intlayer";
    

    or

    tsx
    import "react-intlayer/markdown";
    
    ComponentDescriptionRelated Doc
    HTMLRendererRenders HTML content with custom components.-
    MarkdownProviderProvider for markdown rendering context. Allows custom component overrides for markdown elements.-
    MarkdownRendererRenders markdown content with custom components. Supports all standard markdown features and Intlayer-specific syntax.MarkdownRenderer

    Types

    Import:

    tsx
    import "react-intlayer";
    
    TypeDescription
    IntlayerNodeType representing a node in the Intlayer content tree. Used for type-safe content manipulation.

    Server-side (react-intlayer/server)

    Import:

    tsx
    import "react-intlayer/server";
    
    ExportTypeDescription
    IntlayerServerProviderComponentProvider for server-side rendering. (Intlayer < 9.4)
    IntlayerServerComponentServer-side wrapper for Intlayer content.
    tFunctionServer-side version of the translation function.
    useLocaleHookHook to access locale on the server side.
    useIntlayerHookServer-side version of useIntlayer.
    useDictionaryHookServer-side version of useDictionary.
    useI18nHookServer-side version of useI18n.
    localeFunctionFunction to get or set the locale on the server.