# gt-next: General Translation Next.js SDK: getLocale
URL: https://generaltranslation.com/en-US/docs/next/api/helpers/get-locale.mdx
---
title: getLocale
description: API reference for the getLocale server-side method
---
## Overview
The `getLocale` function retrieves the user's current locale during server-side rendering.
The locale is returned as a BCP 47 [locale code](/docs/core/locales), e.g., `'en-US'`.
`getLocale` is a server-side method and can only be used on server-side
components.
For client-side usage, see [`useLocale`](/docs/next/api/helpers/use-locale).
## Reference
### Returns
A promise that resolves to a string representing the user's current locale, e.g., `'en-US'`.
---
## Fallback behavior
When an unsupported locale is requested, a fallback locale will be selected.
For instance, in the event of an unsupported locale,
if (1) the user has configured multiple preferred locales in their browser settings,
and (2) one of these locales is supported by your application,
then the locale will fallback to the best language.
Additionally, if no possible fallback locales are available,
but two locales share the same language (e.g., `en-US` and `en-GB`),
then the locale will fallback to the supported locale that shares the same language.
If neither condition can be met, then the default locale will be used.
See [`gt.config.json`](/docs/next/api/config/gt-config-json) docs for information on configuring supported locales.
---
## Examples
### Basic usage
Retrieve the user's locale during server-side rendering.
```javascript title="GetUserLocale.jsx" copy
import { getLocale } from 'gt-next/server';
export default async function GetUserLocale() {
const locale = await getLocale(); // [!code highlight]
return
User locale: {locale}
;
}
```
---
## Notes
- The `getLocale` function is asynchronous and must be awaited to retrieve the locale.
- It is specifically designed for server-side use. See [`useLocale`](/docs/next/api/helpers/use-locale) for client-side components.
- The returned locale adheres to the [locale code](/docs/core/locales) format.
## Next steps
- Learn how to configure supported locales with [withGTConfig()](/docs/next/api/config/with-gt-config).