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

    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 documentation
    IntlayerProviderThe main provider that wraps your application and provides the Intlayer context. Includes editor support enabled by default.IntlayerProvider
    IntlayerProviderContentA provider component focused on content, without the editor features. Use this when you do not require the visual editor.-
    HTMLProviderProvider for HTML-related internationalisation settings. Allows component overrides for HTML elements.-

    Hooks

    Import:

    tsx
    import "react-intlayer";
    
    HookDescriptionRelated Doc
    useIntlayerClient-side hook that selects a dictionary by its key and returns its content. Uses the locale from the 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 to manage loading states.-
    useLocaleClient-side hook to get the current locale, default locale, available locales, and a function to change the locale.useLocale
    useLocaleBaseHook to obtain 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. Emulates i18next/next-intl pattern.useI18n
    useIntlHook that provides a locale-bound Intl object. Automatically injects the current locale and uses optimised caching.-
    useLocaleStorageHook that provides locale persistence in localStorage or cookies. Returns getter and setter functions.-
    useLocaleCookieDeprecated. Use useLocaleStorage instead. Hook that manages locale persistence via cookies.-
    useLoadDynamicHook to load dynamic dictionaries using React Suspense. Accepts a key and a promise; caches the results.-
    useIntlayerContextHook that provides the current Intlayer client context values (locale, setLocale, etc.).-
    useHTMLContextHook to access HTML component overrides from the HTMLProvider context.-

    Functions

    Import:

    tsx
    import "react-intlayer";
    
    FunctionDescriptionRelated Doc
    tClient-side translation function that returns the translation of the provided multilingual content. Uses the context locale if none is provided.translation
    getDictionaryProcesses dictionary objects and returns the 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. Optimised version of getDictionary.-
    setLocaleInStorageSets the locale in storage (local storage or cookie, depending on configuration).-
    setLocaleCookieDeprecated. Use setLocaleInStorage instead. Sets the locale in a cookie.-
    localeInStorageRetrieves the locale from storage (local storage or cookie).-
    localeCookieDeprecated. Use localeInStorage instead. Retrieves the locale from a cookie.-

    Components

    Import:

    tsx
    import "react-intlayer";
    

    or

    tsx
    import "react-intlayer/markdown";
    
    ComponentDescriptionRelated documentation
    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.
    IntlayerServerComponentServer-side wrapper for Intlayer content.
    tFunctionServer-side version of the translation function.
    useLocaleHookHook to access the 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.