# gt: General Translation CLI tool: Using automatic JSX injection URL: https://generaltranslation.com/en-US/docs/cli/guides/using-auto-jsx.mdx --- title: Using automatic JSX injection description: How to wrap translatable JSX text in General Translation components at build time with automatic JSX injection. related: links: - /docs/cli/guides/using-autoderive - /docs/cli/guides/generating-translations - /docs/cli/guides/configuring - /docs/cli/guides/managing-translations --- Automatic JSX injection makes the compiler wrap translatable JSX text in [``](/docs/react/reference/components/t) components at build time, so you do not have to add them by hand. Automatic JSX injection is disabled by default. It works in React single-page apps (SPAs) and Next.js webpack builds. ## Enable automatic JSX injection [#enable] Install the compiler: ```bash npm install @generaltranslation/compiler ``` ```bash yarn add @generaltranslation/compiler ``` ```bash bun add @generaltranslation/compiler ``` ```bash pnpm add @generaltranslation/compiler ``` Set `enableAutoJsxInjection` under `files.gt.parsingFlags` in `gt.config.json`. This keeps CLI extraction and compiler transforms in sync. ```json title="gt.config.json" { "files": { "gt": { "parsingFlags": { "enableAutoJsxInjection": true } } } } ``` ## Configure the build [#configure-build] The `gt.config.json` flag takes effect when the General Translation compiler runs. ### React SPAs Add `@generaltranslation/compiler` to your Vite, webpack, Rollup, Rspack, or esbuild configuration. See [Developing with SPA translations](/docs/react/guides/developing-spa-translations#setup) for adapter examples. ### Next.js Configure `gt-next` to use the Babel-based webpack compiler: ```ts title="next.config.ts" import { withGTConfig } from 'gt-next/config'; const nextConfig = {}; export default withGTConfig(nextConfig, { experimentalCompilerOptions: { type: 'babel', enableAutoJsxInjection: true, }, }); ``` Run both the development server and production build with webpack: ```json title="package.json" { "scripts": { "dev": "next dev --webpack", "build": "next build --webpack" } } ``` Next.js 16 uses Turbopack by default. Turbopack disables the Babel compiler, warns that automatic injection will be skipped, and leaves JSX unwrapped. See [Next.js compiler options](/docs/react/nextjs/config#compiler-options). ## How it works [#how] Without injection, you wrap translatable text yourself. ```jsx import { T } from 'gt-react'; function Welcome() { return (

Welcome to our app

); } ``` Next.js projects import [``](/docs/react/reference/components/t) from `gt-next` instead. With injection enabled, the compiler detects the translatable text and wraps it automatically at build time. ```jsx function Welcome() { return

Welcome to our app

; } ``` Text you have already wrapped in [``](/docs/react/reference/components/t), along with other General Translation components such as [``](/docs/react/reference/components/var), [``](/docs/react/reference/components/branch), [``](/docs/react/reference/components/plural), and [``](/docs/react/reference/components/derive), is left untouched. ## Next steps - /docs/cli/guides/using-autoderive - /docs/cli/guides/generating-translations - /docs/cli/guides/configuring - /docs/cli/guides/managing-translations