# gt-next: General Translation Next.js SDK: getTranslations
URL: https://generaltranslation.com/en-US/docs/next/api/dictionary/get-translations.mdx
---
title: getTranslations
description: API reference for the getTranslations server-side translation function
---
## Overview
`getTranslations` is used to get string translations from the [translation dictionary](/docs/next/guides/dictionaries) for server-side components.
```jsx
const d = await getTranslations(); // Get the translation function
d('greeting.hello'); // pass the id to get a translation
```
`getTranslations` supports:
* Translation of string and jsx content.
* Variable insertion and conditional logic within translations.
* Optional id prefixing.
For client-side translations, see [`useTranslations`](/docs/next/api/dictionary/use-translations).
{d('greeting')} // Hello, Alice // [!code highlight]
); } ``` ### Using variables [#variables] In order to pass values, you must (1) assign an identifier and (2) reference the identifier when calling the `d` function. In this example, we use `{}` to pass variables to the translations. In the dictionary, we assign identifier `{userName}`. ```jsx title="dictionary.jsx" copy // [!code word:userName] const dictionary = { greeting: "Hello, {userName}!", // [!code highlight] }; export default dictionary; ``` ```jsx title="TranslateGreeting.jsx" copy // [!code word:userName] import { getTranslations } from 'gt-next/server'; export default async function TranslateGreeting() { const d = await getTranslations(); // Hello Alice! const greetingAlice = d('greeting', { userName: "Alice" }); // [!code highlight] return ({greetingAlice}
); } ``` ### Using prefixes We can use prefixes to only fetch a subset of the dictionary. ```jsx title="dictionary.jsx" copy const dictionary = { prefix1: { // [!code highlight] prefix2: { // [!code highlight] greeting: "Hello, Bob", } } }; export default dictionary; ``` Because we added the value `'prefix1.prefix2'` to the `getTranslations` method, all of the keys are prefixed with `prefix1.prefix2`: ```jsx title="UserDetails.jsx" copy import { getTranslations } from 'gt-next/server'; export default function UserDetails() { const d = await getTranslations('prefix1.prefix2'); // [!code highlight] return ({d('greeting')}
// greeting => prefix1.prefix2.greeting // [!code highlight]