Creation:2026-09-19Last update:2026-09-19
Reference this doc to your favorite AI assistantChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
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.59/19/2026
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 documentationCopy
Copy doc Markdown to clipboard
useIntlayer Hook Documentation
The useIntlayer hook allows you to retrieve localized 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 don't need to pass the locale through route handlers, view templates, or components.
Usage
In Route Handlers
src/server.ts
Copy code
Copy the code to the clipboard
In View Templates / Components
src/views/home.ts
Copy code
Copy the code to the clipboard
Parameters
ts
Copy code
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 (e.g. background tasks or unit tests without middleware), it gracefully falls back to the configured
defaultLocale.
