# gt-next: General Translation Next.js SDK: Overview
URL: https://generaltranslation.com/en-GB/docs/next/introduction.mdx
---
title: Overview
description: Overview of General Translation's Next.js SDK
---
## Introduction
The General Translation Next.js SDK is an open-source internationalisation (i18n) library for Next.js applications.
It provides a comprehensive set of tools to internationalise your Next.js application in a straightforward and maintainable way, with feature parity with other popular i18n libraries. Built on top of the [React SDK](/docs/react), it offers additional Next.js-specific features.
The SDK can be used standalone without the General Translation platform and behaves similarly to other i18n libraries.
However, it also integrates with our platform for enhanced features:
* Translation Hot Reloading in Development
* Automatic AI translations
* Syncing translations with the General Translation platform
* Native integration with our translation CDN
* On-demand translation of React components in production (on the server side)
## Concepts
There are 6 main concepts to understand about the SDK.
Initialisation with [`withGTConfig`](/docs/next/api/config/with-gt-config)
The [``](/docs/next/api/components/gtprovider) component
The [``](/docs/next/api/components/t) component
The [`useGT`](/docs/next/api/strings/use-gt) hook
The [`msg`](/docs/next/api/strings/msg) function for shared strings
(Optional) The [`useTranslations`](/docs/next/api/dictionary/use-translations) hook
## Initialisation with `withGTConfig`
The [`withGTConfig`](/docs/next/api/config/with-gt-config) function initialises the SDK in your Next.js application.
Add it to your `next.config.[js|ts]` file to configure the SDK:
```tsx title="next.config.ts"
import { withGTConfig } from 'gt-next/config';
const nextConfig = {
// Your next.config.ts options
};
export default withGTConfig(nextConfig, {
// Your GT configuration
});
```
See the [withGTConfig API Reference](/docs/next/api/config/with-gt-config) for more information.
## The `` component
The [``](/docs/next/api/components/gtprovider) component provides translation context to your application, including the current language and relevant translations.
```tsx
import { GTProvider } from 'gt-next';
export default function RootLayout({ children }) {
return (
{children}
);
}
```
**Important:** The provider should wrap your entire application and be placed as high in the component tree as possible, such as in your root layout.
The provider is only required for client-side features. Applications that run only on the server don't require it, but it can still be included.
See the [`GTProvider`](/docs/next/api/components/gtprovider) API reference for more information.
## The `` component
The [``](/docs/next/api/components/t) component is the recommended way to translate content in your application.
It is a React component that can be used to wrap any JSX element, and will automatically render the content of the element in a supported language.
We recommend using the [``](/docs/next/api/components/t) component wherever possible, since it allows for the most flexibility in translations.
Unlike strings, the [``](/docs/next/api/components/t) component can be used to translate HTML content, making it far more powerful than string translations.
### Examples
```tsx
Hello, world!
```
```tsx
Here is an image
```
```tsx
Formatting can be done easily with the `` component.
{1000}{new Date()}{1000}
```
The [``](/docs/next/api/components/t) component works with [variable components](/docs/next/guides/variables) like [``](/docs/next/api/components/num), [``](/docs/next/api/components/datetime), and [``](/docs/next/api/components/currency) for dynamic content formatting.
See the [`` component guide](/docs/next/guides/t) to learn about the different ways to use the [``](/docs/next/api/components/t) component.
## The `useGT` hook
The [`useGT`](/docs/next/api/strings/use-gt) hook is a React hook that can be used much like the [``](/docs/next/api/components/t) component, with some trade-offs.
The hook returns a function that can be used to translate strings.
```tsx
const gt = useGT();
gt('Hello, world!');
```
Compared with the [``](/docs/next/api/components/t) component, the [`useGT`](/docs/next/api/strings/use-gt) hook offers greater flexibility in your codebase.
For example, if you have a complex data structure with nested strings, a [``](/docs/next/api/components/t) component would be harder to use.
```tsx
const gt = useGT();
const data = {
title: gt('Hello, world!'),
description: gt('This is a description'),
};
```
See the [strings](/docs/next/guides/strings) guide to learn more about the [`useGT`](/docs/next/api/strings/use-gt) hook.
## The `msg` function
The [`msg`](/docs/next/api/strings/msg) function is used to mark strings for translation that are used across multiple components or stored in configuration objects.
This is particularly useful for shared content such as navigation labels, form messages or any text that appears in multiple places throughout your application.
```tsx
// Mark strings for translation
import { msg } from 'gt-next';
const navItems = [
{ label: msg('Home'), href: '/' },
{ label: msg('About'), href: '/about' },
{ label: msg('Contact'), href: '/contact' }
];
```
```tsx
// Decode and use the marked strings
import { useMessages } from 'gt-next';
function Navigation() {
const m = useMessages();
return (
);
}
```
The [`msg`](/docs/next/api/strings/msg) function encodes strings with translation metadata, and [`useMessages`](/docs/next/api/strings/use-messages) (or [`getMessages`](/docs/next/api/strings/get-messages) for server components) decodes them.
Use [`msg`](/docs/next/api/strings/msg) for shared content that needs to be translated consistently across your application. For component-specific content, prefer [``](/docs/next/api/components/t) or [`useGT`](/docs/next/api/strings/use-gt).
See the [shared strings](/docs/next/guides/shared-strings) guide to learn more about the `msg` function.
## The `useTranslations` hook
The [`useTranslations`](/docs/next/api/dictionary/use-translations) hook is a React hook that returns a function that can be used to retrieve translations for a given key.
```tsx title="dictionary.ts"
const dictionary = {
hello: {
world: 'Hello, world!',
},
};
```
```tsx title="App.tsx"
const translate = useTranslations();
translate('hello.world');
```
This behaviour is similar to other translation libraries, such as [`react-i18next`](https://react.i18next.com/) and [`next-intl`](https://next-intl-docs.vercel.app/).
We do not recommend using the [`useTranslations`](/docs/next/api/dictionary/use-translations) hook in your application. Frequent use of the [`useTranslations`](/docs/next/api/dictionary/use-translations) hook will make your codebase more difficult to maintain,
and will lead to significant technical debt.
Instead, we recommend using the [``](/docs/next/api/components/t) component or the [`useGT`](/docs/next/api/strings/use-gt) hook.
If you are migrating from another i18n library, the [`useTranslations`](/docs/next/api/dictionary/use-translations) hook is a drop-in replacement and can be useful for incrementally migrating your codebase.
See the [dictionaries](/docs/next/guides/dictionaries) guide to learn more about the [`useTranslations`](/docs/next/api/dictionary/use-translations) hook.
See the [useTranslations API Reference](/docs/next/api/dictionary/use-translations) for more information.
***
## Next steps
**See it in action:** Browse [working example apps](/docs/next/tutorials/examples) showcasing each pattern, or explore the full [app catalogue](https://app-catalog.generaltranslation.dev).
* Learn how to set up your Next.js project with the SDK: [Quickstart](/docs/next)
* Learn how to translate JSX content with the [``](/docs/next/api/components/t) component: [JSX Translation Guide](/docs/next/guides/t)
* Learn how to translate strings with the [`useGT`](/docs/next/api/strings/use-gt) hook: [String Translation Guide](/docs/next/guides/strings)
* Learn about shared strings with the [`msg`](/docs/next/api/strings/msg) function: [Shared Strings Guide](/docs/next/guides/shared-strings)