# gt-next: General Translation Next.js SDK: The T Component URL: https://generaltranslation.com/en-US/docs/next/guides/t.mdx --- title: The T Component description: How to internationalize JSX components using the T component --- {/* AUTO-GENERATED: Do not edit directly. Edit the template in content/docs-templates/ instead. */} The [`` component](/docs/next/api/components/t) is the primary tool for internationalizing JSX content in your Next.js application. It wraps your JSX elements and automatically translates them based on the user's locale. ## Quickstart Transform any static JSX content by wrapping it with [``](/docs/next/api/components/t): ```jsx import { T } from 'gt-next'; // Before function Greeting() { return

Hello, world!

; } // After function Greeting() { return

Hello, world!

; } ``` For dynamic content within [``](/docs/next/api/components/t), use [Variable Components](/docs/next/guides/variables) and [Branching Components](/docs/next/guides/branches). ## Basic usage The [`` component](/docs/next/api/components/t) accepts any JSX content as children: ```jsx // Simple text Welcome to our app // HTML elements

Page Title

// Complex nested JSX
Important: Please read carefully.
``` ## Configuration options ### Adding context Provide translation context for ambiguous terms: ```jsx Click the toast to dismiss ``` ## When to use T Use [``](/docs/next/api/components/t) for **static content only**: ```jsx // ✅ Static content works

Welcome to our site

// ❌ Dynamic content breaks

Hello {username}

Today is {new Date()}

// ✅ Use Variable components for dynamic content

Hello {username}

``` Variable and Branching components are designed to work inside [``](/docs/next/api/components/t) for dynamic content. See [Variable Components](/docs/next/guides/variables) and [Branching Components](/docs/next/guides/branches) guides for details. ## Examples ### Simple elements ```jsx // Basic text Hello, world! // Button with text // Heading with styling

Welcome

``` ### Complex components ```jsx // Navigation menu // Alert message
Your session expires in 5 minutes
``` ### With variables You can use variable components for localized formatting. ```jsx // Combining static text with dynamic values

Welcome back, {user.name}!

You have {user.friends.length} friends online

Your birthday is {user.birthday}

Your balance is {user.balance}

``` Learn more about the [`` component](/docs/next/api/components/var) in the [Variable Components Guide](/docs/next/guides/variables). ## Production setup ### Build process Add translation to your build pipeline: ```json title="package.json" { "scripts": { "build": "npx gtx-cli translate && <...YOUR_BUILD_COMMAND...>" } } ``` ### Development vs production behavior - **Development**: With a dev API key, translations happen on-demand when components render. You'll see real-time translation as you develop. - **Production**: All translations are pre-built during the build stage and will be visible once your application is live. Set your development API key in your environment to enable live translation during development. You can create one in the Dashboard under [API Keys](https://dash.generaltranslation.com/en-US/project/api-keys). ### Privacy considerations Content in [``](/docs/next/api/components/t) components is sent to the GT API for translation. For sensitive data, use [Variable Components](/docs/next/guides/variables#privacy) to keep private information local: ```jsx // Safe - sensitive data stays local Welcome back, {username} ``` ## Common issues ### Component boundaries [``](/docs/next/api/components/t) only translates direct children, not content inside other components: ```jsx // ❌ Wrong - content inside components won't be translated function MyComponent() { return

This won't be translated

; }

This will be translated

{/* Content inside won't be translated */}
// ✅ Correct - wrap each component individually function MyComponent() { return

This will be translated

; }

This will be translated

``` ### Nesting T components ```jsx // ❌ Don't nest components Hello world {/* Don't do this */} ``` ### Dynamic content errors The CLI will error on dynamic content in [``](/docs/next/api/components/t). Wrap dynamic values with Variable components: ```jsx // ❌ Wrong - dynamic content breaks

Hello {username}

// ✅ Correct - use Variable components

Hello {username}

``` See the [Variable Components Guide](/docs/next/guides/variables) for handling dynamic values and the [Branching Components Guide](/docs/next/guides/branches) for conditional content. ## Next steps - [Variable Components Guide](/docs/next/guides/variables) - Handle dynamic content within JSX translations - [Branching Components Guide](/docs/next/guides/branches) - Add conditional logic to your translations