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
useLocale Hook Documentation
The useLocale hook from remix-intlayer provides access to the locale of the HTTP request currently being processed, along with the project's configured default and available locales.
Usage
In a Remix component (for example a language switcher):
src/components/LocaleSwitcher.tsx
Copy code
Copy the code to the clipboard
In a route handler:
src/server.ts
Copy code
Copy the code to the clipboard
Return Values
The hook returns an object of type UseLocaleResult:
Show all table content
Open the table in a modal to view all data content clearly
| Property | Type | Description |
|---|---|---|
locale | DeclaredLocales | The locale resolved for the current request. |
defaultLocale | DeclaredLocales | The default fallback locale configured in intlayer.config.ts. |
availableLocales | DeclaredLocales[] | Array of all available locales configured in intlayer.config.ts. |
Description
- Request-Scoped Resolution: In an active request handled by the
intlayer()middleware,useLocalereads the resolved locale from the request storage. - Graceful Fallback: If called outside of a request context (such as during initialization scripts or test suites), it defaults to the configured
defaultLocale.
