Overview

Quickstart

Never expose a project API key in a publicly accessible production app. Use the credential model recommended by your Tolgee deployment.

Install the SDK#

npm install @tolgee/web
pnpm add @tolgee/web
1
Create a Tolgee instance

The public Tolgee integration guide uses @tolgee/web, FormatSimple, DevTools, and BackendFetch.

import { Tolgee, FormatSimple, DevTools, BackendFetch } from '@tolgee/web';
 
const tolgee = Tolgee()
  .use(DevTools())
  .use(FormatSimple())
  .use(BackendFetch())
  .init({
    apiKey: '<PROJECT_API_KEY>',
    apiUrl: '<TOLGEE_API_URL>',
    defaultLanguage: 'en',
    observerType: 'text',
    observerOptions: { inputPrefix: '{{', inputSuffix: '}}' },
  });
 
tolgee.run();
2
Use a translation
tolgee.on('update', () => {
  document.title = tolgee.t('tolgee_example_title', { noWrap: true });
});

Output: the document title is updated from the translation key when Tolgee loads or updates it.

3
Continue in the official docs

The exact project setup, framework adapters, and production configuration depend on your app. Continue with the Tolgee JavaScript SDK documentation.

Next steps#

Updated

Was this page helpful?