# General Translation React SDKs (gt-react, gt-next): tx URL: https://generaltranslation.com/it/docs/react/nextjs/reference/functions/tx.mdx --- title: tx description: Traduce le stringhe in fase di richiesta nel codice server di Next.js App Router con General Translation. Riferimento API per tx. --- La funzione `tx` traduce una stringa in fase di richiesta tramite l'API di General Translation. Usala per il contenuto dinamico che non è noto al build time; usa [`getGT`](/docs/react/nextjs/reference/functions/get-gt) per le stringhe sorgente statiche. `tx` è disponibile solo lato server e non funziona con il Pages Router. ## Panoramica [#overview] ```tsx import { tx } from 'gt-next/server'; const translated = await tx('A message loaded at request time'); ``` ## Parametri [#parameters] | Parametro | Descrizione | Tipo | Facoltativo | Predefinito | | --------- | ------------------------------------------------------------------------------------------------------------ | -------- | ----------- | ----------- | | `message` | Stringa da tradurre. | `string` | No | — | | `options` | Impostazione regionale di destinazione, context, formato, limite di lunghezza e variabili di interpolazione. | `object` | Sì | `{}` | `options` accetta `$locale`, `$context`, `$maxChars` e `$format`. Passa le variabili di interpolazione come chiavi di primo livello. ## Restituisce [#returns] **Tipo** `Promise` Una promise che si risolve nella stringa tradotta, oppure nella stringa sorgente quando la traduzione è disabilitata o non necessaria. ## Esempio [#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

{translated}

; } ```