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 withGTConfig for configuration.
If no default locale is specified in withGTConfig, 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.
"use client";
import { useDefaultLocale } from 'gt-next';
export default function DefaultLocale() {
    const defaultLocale = useDefaultLocale();
    return <p>Default locale: {defaultLocale}</p>; // Display the default locale
}Notes
- The useDefaultLocalehook relies on the<GTProvider>to access the context. Ensure your app is wrapped with a provider at the root level.
- useDefaultLocaleis client-side only.
- Learn more about locale strings here.
Next Steps
- See useLocaleandgetLocaleto retrieve the user's locale.
- Explore getDefaultLocalefor retrieving the default locale in server components.
How is this guide?

