Skip to content

Quick Start

This guide gets you from zero to translated UI in a few minutes.

  1. Install Comvi i18n

    Terminal window
    npm install @comvi/react
  2. Create and configure your i18n instance

    src/i18n.ts
    import { createI18n } from '@comvi/react';
    export const i18n = createI18n({
    locale: 'en',
    translation: {
    en: {
    'hello': 'Hello, {name}!',
    'legal.tos': 'Read our <link>Terms of Service</link>',
    },
    de: {
    'hello': 'Hallo, {name}!',
    'legal.tos': 'Lies unsere <link>Nutzungsbedingungen</link>',
    },
    },
    });
  3. Wire i18n into your app

    src/main.tsx
    import { StrictMode } from 'react';
    import { createRoot } from 'react-dom/client';
    import { I18nProvider } from '@comvi/react';
    import { i18n } from './i18n';
    import App from './App';
    createRoot(document.getElementById('root')!).render(
    <StrictMode>
    <I18nProvider i18n={i18n}>
    <App />
    </I18nProvider>
    </StrictMode>,
    );

    useI18n() throws if used outside <I18nProvider>.

  4. Use translations in your components

    src/App.tsx
    import { useI18n, T } from '@comvi/react';
    function App() {
    const { t } = useI18n();
    return (
    <div>
    <h1>{t('hello', { name: 'World' })}</h1>
    <T
    i18nKey="legal.tos"
    components={{ link: <a href="/terms" /> }}
    />
    </div>
    );
    }
    export default App;

That’s it — your app renders translated strings reactively. The t() function returns translations, and framework bindings use the <T> component for tags embedded in strings.