Next.jsHelpers
useDefaultLocale()
API Reference for the useDefaultLocale hook
Overview
The useDefaultLocale
hook retrieves the application's default locale from the <GTProvider>
context.
This locale represents the fallback language for your app and is typically used when a user's preferred locale is unavailable.
useDefaultLocale
is a client-side hook and can only be used on client-side components.
Ensure your app is wrapped in a <GTProvider>
.
See initGT()
for configuration.
If no default locale is specified in initGT()
it defaults to 'en-US'
.
For server-side, see getDefaultLocale()
.
Reference
Returns
A string representing the application's default locale, e.g., 'en-US'
.
Examples
Basic Usage
Retrieve the application's default locale and display it in your component.
Notes
- The
useDefaultLocale()
hook relies on the<GTProvider>
to access the context. Ensure your app is wrapped with a provider at the root level. useDefaultLocale()
is client-side only.- Learn more about locale strings here.
Next Steps
- See
useLocale
andgetLocale
to retrieve the user's locale. - Explore
getDefaultLocale()
for retrieving the default locale in server components.