# General Translation React SDKs (gt-react, gt-next, gt-react-native): getLocale
URL: https://generaltranslation.com/en-US/docs/react/nextjs/reference/functions/get-locale.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Read the current Next.js App Router request locale with General Translation. API reference for getLocale.

The `getLocale` function returns the locale for the current App Router request as a BCP 47 locale code. Import it from `gt-next/server` in async components, Route Handlers, and other server code.

`getLocale` is server-only and does not work with the Pages Router.

## Overview [#overview]

```tsx
import { getLocale } from 'gt-next/server';

const locale = await getLocale(); // 'en-US'
```

## Returns [#returns]

**Type** `Promise<string>`

A promise resolving to the current request locale. General Translation resolves the locale through the configured request locale function and falls back to the default locale when needed.

## Invalid locale behavior [#invalid-locales]

When the request locale is unsupported, `gt-next` warns and returns `defaultLocale`. Set [`disableInvalidLocaleWarning`](/docs/react/nextjs/config#disable-invalid-locale-warning) to suppress the warning without changing the fallback.

For a strict `[locale]` route, check the route parameter with [`isLocaleSupported`](/docs/react/nextjs/reference/functions/is-locale-supported) and call Next.js `notFound()` before rendering. `getLocale` does not create a 404 automatically.

## Example [#example]

```tsx title="app/[locale]/layout.tsx"
import { getLocale } from 'gt-next/server';

export default async function LocaleLayout({ children }) {
  const locale = await getLocale();
  return <html lang={locale}>{children}</html>;
}
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
