# gt-next: General Translation Next.js SDK: getGT
URL: https://generaltranslation.com/en-GB/docs/next/api/strings/get-gt.mdx
---
title: getGT
description: API reference for the getGT() string translation function
---
## Overview
The `getGT` function is an async function for translating strings at build time.
```jsx
const gt = await getGT();
{ gt('This text will be translated') }
;
```
**Build-time Translation:**
`getGT` translations occur at build time, before your app deploys.
Although you can pass variables to the translated string, you can only translate content known at build time.
## Reference
### Parameters
None
### Returns
A promise resolving to the callback function, `gt`, which translates the provided content.
```jsx
Promise<(content: string, options?: InlineTranslationOptions) => string>
```
| Name | Type | Description |
| ---------- | ----------------------------------------------------------------------------- | ------------------------------------------------------- |
| `content` | `string` | The string to be translated. |
| `options?` | [`InlineTranslationOptions`](/docs/next/api/types/inline-translation-options) | Translation options to customise the behaviour of `gt`. |
***
## Behaviour
### Production
During the CD process, any content inside a `gt` function will be translated before your application is deployed.
This ensures fast load times for all locales, but it can only translate content known at build time.
Once generated, translations are either (1) stored in the CDN or (2) stored in your app's build output, according to your configuration.
From there, the translated content is served to your users.
If a translation is not found, it will fall back to the original content.
Make sure to follow the [deployment guide here](/docs/next/tutorials/quickdeploy).
### Development
During development, the `gt` function will translate content on-demand.
This is useful for prototyping how your app will look in different languages.
Remember to add a Dev API key to your environment to enable this behaviour.
You will see a delay when on-demand translation runs in development.
This will not occur in production builds unless content is explicitly being translated on-demand,
i.e. using [`tx`](/docs/next/api/strings/tx) or [``](/docs/next/api/components/tx).
***
## Example
### Basic usage
You can use `getGT` to translate strings.
```javascript copy
import { getGT } from 'gt-next/server';
export default async function TranslateGreeting() {
const gt = await getGT();
return (
{gt('Hello, Alice!')}
);
}
```
Note: "Alice" will be translated to the user's preferred language.
### Using variables [#variables]
You can pass variables to dictionary translations.
```javascript copy
import { getGT } from 'gt-next/server';
export default async function TranslateGreeting() {
const gt = await getGT();
return (
{gt('Hello, {name}!', { name: 'Alice' })}
);
}
```
Note: "Alice" will not be translated into the user's preferred language because it is a variable.
### Translating page metadata [#metadata]
Use `getGT` inside Next.js `generateMetadata` to translate page titles, descriptions, and Open Graph tags.
```javascript copy
import { getGT } from 'gt-next/server';
import { Metadata } from 'next';
export async function generateMetadata(): Promise {
const gt = await getGT();
return {
title: gt('My App'),
description: gt('A fast, modern web application'),
openGraph: {
title: gt('My App'),
description: gt('A fast, modern web application'),
},
};
}
```
### Using ICU message format
`gt-next` supports ICU message format, which also lets you format your variables.
```javascript copy
import { getGT } from 'gt-next/server';
export default async function TranslateGreeting() {
const gt = await getGT();
return (
{gt('There are {count, plural, =0 {no items} =1 {one item} other {{count} items}} in the cart', { count: 10 })}
);
}
```
ICU message format is a powerful way of formatting your variables.
For more information, see the [ICU message format documentation](https://unicode-org.github.io/icu/userguide/format_parse/messages/).
***
## Notes
* The `getGT` function is a server-side function that translates strings.
* String translations with `getGT` happen before runtime, during the build process (unless in development).
## Next steps
* See [`useGT`](/docs/next/api/strings/use-gt) for client-side string translations at build time.
* For runtime translations, see [`tx`](/docs/next/api/strings/tx) and [``](/docs/next/api/components/tx).