# node: initializeGT URL: https://generaltranslation.com/en-US/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`, or any other translation function. Call it once during your server's initialization (e.g., at the top of your entry file). ## Reference ### Parameters ### 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 development environment on-demand translations. | | `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. | | `loadTranslations` | A custom function to load translations from your own source. | ### 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 strings.