Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init doc"v9.5.519/09/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf 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 doc Markdown to clipboard
useIntlayer Hook Documentation
The useIntlayer hook allows you to retrieve localised content from an Intlayer dictionary by key in Remix 3 applications.
It automatically reads the active locale from the current request context (via AsyncLocalStorage), so you do not need to pass the locale through route handlers, view templates, or components.
Usage
In Route Handlers
Copy the code to the clipboard
In View Templates / Components
Copy the code to the clipboard
Parameters
Copy the code to the clipboard
key: The unique key of the dictionary (as defined in your.content.tsdeclaration files).localeOrSelector(optional): A specific locale or selector object ({ item },{ variant }, optionally withlocale). When provided, it overrides the locale detected from the request context.
Description
The hook performs the following tasks:
- Context Locale Retrieval: Detects the current locale from the request-bound
AsyncLocalStoragescope established by theintlayer()middleware. - Dictionary Retrieval: Retrieves the pre-compiled dictionary corresponding to the provided key.
- Translation Processing: Resolves translations, enumerations, markdown, and conditional content for the resolved locale.
- Fallback Handling: If called outside of an active HTTP request context, it gracefully falls back to the configured
defaultLocale.
