# gt-next: General Translation Next.js SDK: useLocaleDirection URL: https://generaltranslation.com/en-US/docs/next/api/helpers/use-locale-direction.mdx --- title: useLocaleDirection description: API reference for the useLocaleDirection hook --- {/* AUTO-GENERATED: Do not edit directly. Edit the template in content/docs-templates/ instead. */} ## Overview The `useLocaleDirection` hook retrieves the text direction (`'ltr'` or `'rtl'`) for the current or a specified locale from the [`` context](/docs/next/api/components/gtprovider). `useLocaleDirection` is a client-side hook and *can only be used in client-side components*. Ensure your app is wrapped in a [``](/docs/next/api/components/gtprovider). For server-side usage, see [`getLocaleDirection`](/docs/next/api/helpers/get-locale-direction). ## Reference ### Parameters | Parameter | Type | Description | | --- | --- | --- | | `locale` | `string` (optional) | A BCP 47 locale code (e.g., `'ar'`, `'en-US'`). If omitted, the current locale from context is used. | ### Returns `'ltr' | 'rtl'` — The text direction for the locale. --- ## Examples ### Get direction for the current locale ```jsx title="DirectionWrapper.jsx" copy 'use client'; import { useLocaleDirection } from 'gt-next'; export default function DirectionWrapper({ children }) { const dir = useLocaleDirection(); // [!code highlight] return
{children}
; } ``` ### Get direction for a specific locale ```jsx title="SpecificDirection.jsx" copy 'use client'; import { useLocaleDirection } from 'gt-next'; export default function SpecificDirection() { const dir = useLocaleDirection('ar'); // 'rtl' [!code highlight] return

Arabic text direction: {dir}

; } ``` --- ## Notes - Unlike the server-side [`getLocaleDirection`](/docs/next/api/helpers/get-locale-direction), this hook is always synchronous. - Useful for setting the `dir` attribute on elements for RTL support. ## Next steps - Learn about RTL support in the [right-to-left guide](/docs/next/guides/rtl). - See [`getLocaleDirection`](/docs/next/api/helpers/get-locale-direction) for the server-side equivalent.