# General Translation React SDKs (gt-react, gt-next, gt-react-native): tx
URL: https://generaltranslation.com/en-US/docs/react/nextjs/reference/functions/tx.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Translate request-time strings in Next.js App Router server code with General Translation. API reference for tx.

The `tx` function translates a string at request time through the General Translation API. Use it for dynamic content that is not known at build time; use [`getGT`](/docs/react/nextjs/reference/functions/get-gt) for static source strings.

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

## Overview [#overview]

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

const translated = await tx('A message loaded at request time');
```

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| `message` | String to translate. | `string` | No | — |
| `options` | Target locale, context, format, length limit, and interpolation variables. | `object` | Yes | `{}` |

`options` accepts `$locale`, `$context`, `$maxChars`, and `$format`. Pass interpolation variables as top-level keys. `$maxChars` requests a positive-integer maximum from the translation service and cuts the returned string to that length if needed.

## Returns [#returns]

**Type** `Promise<string>`

A promise resolving to the translated string, or the source string when translation is disabled or unnecessary.

## Example [#example]

```tsx title="app/notes/[id]/page.tsx"
import { tx } from 'gt-next/server';

export default async function NotePage({ params }) {
  const note = await loadNote((await params).id);
  const translated = await tx(note, {
    $context: 'A user-created note',
  });
  return <p>{translated}</p>;
}
```

## Sitemap

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