# gt-next: General Translation Next.js SDK: isLocaleSupported URL: https://generaltranslation.com/en-US/docs/next/api/helpers/is-locale-supported.mdx --- title: isLocaleSupported description: API reference for the isLocaleSupported server-side method --- ## Overview The `isLocaleSupported` function checks whether a locale is valid and supported by your app's current gt-next configuration. Use it when a route param or other request input should be explicitly rejected instead of silently falling back to the default locale. A common pattern is validating the `[locale]` segment in a dynamic route and calling `notFound()` when the value is not supported. `isLocaleSupported` is a server-side method and can only be used on server-side components. ## Reference ### Parameters | Name | Description | |----------|----------------------------------------------------------------------------------------------------------| | `locale` | The locale candidate to validate. Any value is accepted; non-string or invalid BCP 47 values return `false`. | ### Returns A `boolean` that is `true` when the locale resolves to one of the configured locales, and `false` otherwise. It also acts as a TypeScript type guard (`locale is string`), narrowing the value to `string` when it returns `true`. --- ## Examples ### Rejecting invalid route params Validate the `[locale]` route param and call `notFound()` for unsupported locales instead of relying on the default-locale fallback. ```tsx title="app/[locale]/page.tsx" copy import { notFound } from 'next/navigation'; import { isLocaleSupported } from 'gt-next/server'; export default async function Page({ params, }: { params: Promise<{ locale: string }>; }) { const { locale } = await params; if (!isLocaleSupported(locale)) { notFound(); // [!code highlight] } return

Locale: {locale}

; } ``` --- ## Notes - `isLocaleSupported` is server-side only. - Without this check, an invalid or unsupported request locale falls back to the default locale rather than throwing. See [`getLocale`](/docs/next/api/helpers/get-locale) for the fallback behavior. - The set of supported locales is configured in [`withGTConfig`](/docs/next/api/config/with-gt-config). See also [`gt.config.json`](/docs/next/api/config/gt-config-json). ## Next steps - See [`getLocale`](/docs/next/api/helpers/get-locale) to retrieve the user's current locale. - Learn how to configure supported locales with [`withGTConfig()`](/docs/next/api/config/with-gt-config).