# General Translation React SDKs (gt-react, gt-next): Translating strings URL: https://generaltranslation.com/en-GB/docs/react/guides/translating-strings.mdx --- title: Translating strings description: How to translate standalone strings such as labels and placeholders with the General Translation useGT hook across React, Next.js, TanStack Start, and React Native. related: links: - /docs/react/guides/translating-jsx - /docs/react/guides/formatting-variables - /docs/react/guides/handling-plurals-and-branches - /docs/react/guides/translating-with-dictionaries --- Some text is not JSX — placeholders, `aria-label`s, alt text, and strings you build in code. Use the [`useGT`](/docs/react/reference/hooks/use-gt) hook to translate these. In async App Router components, use [`getGT`](/docs/react/nextjs/reference/functions/get-gt) instead. ## Translate with `useGT` [#use-gt] Call `useGT` to get a translation function, then pass it your source string. `useGT` returns the function directly. ```tsx import { useGT } from 'gt-react'; function Search() { const gt = useGT(); return ; } ``` ```tsx title="Synchronous components" import { useGT } from 'gt-next'; function Search() { const gt = useGT(); return ; } ``` ```tsx title="Async App Router components" import { getGT } from 'gt-next/server'; async function Search() { const gt = await getGT(); return ; } ``` ```tsx import { useGT } from 'gt-tanstack-start'; function Search() { const gt = useGT(); return ; } ``` ```tsx import { useGT } from 'gt-react-native'; function Search() { const gt = useGT(); return ; } ``` *Note: Write `const gt = useGT()` — the hook returns the function itself, not an object. Pass a string literal, not a template literal or concatenation, so the CLI can extract it.* ## Insert variables [#variables] Use ICU message syntax with a named placeholder, and pass the value in the options object. This is identical across frameworks. ```tsx const gt = useGT(); gt('Welcome back, {name}!', { name: user.name }); ``` ## Add context [#context] Pass `$context` to disambiguate a string, and `$id` to give it a stable identifier. ```tsx gt('Bank', { $context: 'a bank of a river' }); ``` ## Reuse strings defined outside components [#shared] To define translatable strings at module scope — for constants, enums, or config — register them with [`msg`](/docs/react/reference/functions/msg) and resolve them with [`useMessages`](/docs/react/reference/hooks/use-messages). In async App Router components, use [`getMessages`](/docs/react/nextjs/reference/functions/get-messages) instead. Register the string once with `msg`, then resolve it where you render. ```tsx import { msg, useMessages } from 'gt-react'; const STATUS = { active: msg('Active'), paused: msg('Paused') }; function Badge({ status }: { status: 'active' | 'paused' }) { const m = useMessages(); return {m(STATUS[status])}; } ``` ```tsx title="Synchronous components" import { msg, useMessages } from 'gt-next'; const STATUS = { active: msg('Active'), paused: msg('Paused') }; function Badge({ status }: { status: 'active' | 'paused' }) { const m = useMessages(); return {m(STATUS[status])}; } ``` ```tsx title="Async App Router components" import { msg } from 'gt-next'; import { getMessages } from 'gt-next/server'; const STATUS = { active: msg('Active'), paused: msg('Paused') }; async function Badge({ status }: { status: 'active' | 'paused' }) { const m = await getMessages(); return {m(STATUS[status])}; } ``` ```tsx import { msg, useMessages } from 'gt-tanstack-start'; const STATUS = { active: msg('Active'), paused: msg('Paused') }; function Badge({ status }: { status: 'active' | 'paused' }) { const m = useMessages(); return {m(STATUS[status])}; } ``` ```tsx import { msg, useMessages } from 'gt-react-native'; const STATUS = { active: msg('Active'), paused: msg('Paused') }; function Badge({ status }: { status: 'active' | 'paused' }) { const m = useMessages(); return {m(STATUS[status])}; } ``` ## Next steps - /docs/react/guides/translating-jsx - /docs/react/guides/formatting-variables - /docs/react/guides/handling-plurals-and-branches - /docs/react/guides/translating-with-dictionaries