# node: initializeGT
URL: https://generaltranslation.com/en-GB/docs/node/api/initialize-gt.mdx
---
title: initializeGT
description: API reference for the initializeGT setup function
---
## Overview
The `initializeGT` function configures General Translation for use in a Node.js runtime.
It must be called once before any translation functions are used.
```js
import { initializeGT } from 'gt-node';
initializeGT({
defaultLocale: 'en-US',
locales: ['en-US', 'es', 'fr'],
projectId: 'your-project-id',
});
```
**Required setup:**
`initializeGT` must be called before using `withGT`, `getGT`, `getMessages`, `getTranslations`, or any other translation function.
Call it once during your server's initialisation (e.g. at the top of your entry file).
## Reference
### Parameters
>',
optional: true,
},
"enableI18n?": {
type: 'boolean',
optional: true,
},
"cacheExpiryTime?": {
type: 'number',
optional: true,
},
}}
/>
### Description
| Prop | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------- |
| `defaultLocale` | The default locale for your application. Defaults to `'en-US'`. |
| `locales` | An array of locale codes your application supports. |
| `projectId` | Your General Translation project ID, required for cloud translation services. |
| `devApiKey` | API key for on-demand translations in the development environment. |
| `cacheUrl` | URL of the GT cache service. Set to `null` to disable. |
| `runtimeUrl` | URL of the GT runtime translation service. Set to `null` to disable. |
| `dictionary` | A source-language dictionary object for use with [`getTranslations`](/docs/node/api/get-translations). |
| `loadDictionary` | An async function that loads a translated dictionary for a given locale. Requires `dictionary` to be set. |
| `loadTranslations` | A custom function to load translations from your own source. |
| `customMapping` | A mapping of custom locale codes to standard locale codes or locale properties. |
| `enableI18n` | Whether to enable i18n features. |
| `cacheExpiryTime` | Time in milliseconds before cached translations expire. |
### Returns
`void`
***
## Examples
### Basic setup
```js title="server.js"
import { initializeGT } from 'gt-node';
initializeGT({
defaultLocale: 'en-US',
locales: ['en-US', 'es', 'fr', 'ja'],
projectId: process.env.GT_PROJECT_ID,
});
```
### With a custom translation loader
```js title="server.js"
import { initializeGT } from 'gt-node';
initializeGT({
defaultLocale: 'en-US',
locales: ['en-US', 'es'],
loadTranslations: async (locale) => {
const res = await fetch(`https://my-api.com/translations/${locale}`);
return res.json();
},
});
```
***
## Notes
* `initializeGT` must be called **once** before any translation functions are used.
* If using GT cloud services, provide `projectId`. For development, also provide `devApiKey`.
* The `loadTranslations` option lets you bring your own translation source instead of using GT's CDN.
## Next steps
* See [`withGT`](/docs/node/api/with-gt) to provide locale context for each request.
* See [`getGT`](/docs/node/api/get-gt) and [`getMessages`](/docs/node/api/get-messages) for translating inline strings.
* See [`getTranslations`](/docs/node/api/get-translations) for dictionary-based translations.