Next.jsHelpers
getDefaultLocale()
API Reference for the getDefaultLocale server-side method
Overview
The getDefaultLocale()
function retrieves the application's default locale.
This locale is determined when the server starts and is used as the fallback language for translations.
It returns a locale string, e.g., 'en-US'
.
getDefaultLocale()
is a server-side method and can only be used on server-side components.
See initGT()
for configuration.
If no default locale is specified in initGT()
it defaults to 'en-US'
.
For client-side, see useDefaultLocale()
.
Reference
Returns
A string representing the application's default locale, e.g., 'en-US'
.
Examples
Basic Usage
Retrieve the application's default locale and use it in your server-side logic.
Notes
- The
getDefaultLocale()
returns the default locale set ininitGT()
. getDefaultLocale()
is server-side only.- The returned locale adheres to the locale strings format.
Next Steps
- See
useLocale()
andgetLocale()
to retrieve the user's locale. - Explore
useDefaultLocale()
for retrieving the default locale in client components.