Usage
Reads the authoritative Astryx locale. Use it to thread the provider locale into pure formatting helpers and sibling-package APIs; do not derive a second locale from navigator.language or a hardcoded literal.
tsimport {useLocale} from '@astryxdesign/core/i18n'
Best practices
| Guidance | Practices |
|---|---|
| Do | Pass the returned locale to pure Astryx helpers or package APIs that require an explicit locale. |
| Don't | Use navigator.language or a hardcoded display locale as a fallback; InternationalizationProvider is the locale source. |
Returns
| Field | Type | Description |
|---|---|---|
| locale | The active InternationalizationProvider BCP 47 locale. Falls back to 'en' when no provider is present. |
Examples
Common configurations, variations, and states.An invoice summary that formats its date and amount with Intl using the locale from useLocale, so switching the provider from English to German changes "Nov 2, 2026" and "$1,234.50" to "2. Nov. 2026" and "1.234,50 $" with no second locale source.
Use with shadcn
Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.
This install URL expires with the draft preview.bashnpx shadcn@4.19.0 add https://astryx-4faxl496o-fbopensource.vercel.app/shadcn/hooks/use-locale.json