# gt-next: General Translation Next.js SDK: getLocale
URL: https://generaltranslation.com/en-GB/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 behaviour
When an unsupported locale is requested, a fallback locale will be selected.
For example, if an unsupported locale is requested,
and (1) the user has configured multiple preferred locales in their browser settings,
and (2) one of those locales is supported by your application,
then the locale will fall back to the best match.
Additionally, if no fallback locales are available,
but two locales share the same language (e.g. `en-US` and `en-GB`),
then the locale will fall back to the supported locale that shares that language.
If neither condition can be met, the default locale will be used.
See the [`gt.config.json`](/docs/next/api/config/gt-config-json) docs for information on configuring supported locales.
***
## Examples
### Basic usage
Get 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).