Skip to content
Vite i18n

Vite i18n without slowing down development

Use Lefine with Vite projects to keep hot reload fast and locale content easy to ship across app and marketing surfaces.

Package
lefine
Entry
lefine/react
lefine
01Terminal
npm install lefine
02src/App.tsx
import { StringsProvider, useStrings } from 'lefine/react';function LandingHero() {  const t = useStrings('landing');  return (    <section>      <h1>{t('headline')}</h1>      <p>{t('subheadline')}</p>    </section>  );}// props = await strings.load(locale, ['landing']) on the serverexport default function App({ props }) {  return (    <StringsProvider {...props}>      <LandingHero />    </StringsProvider>  );}
t('headline')
Built for every market

Typical Vite setup

A minimal provider-based setup for Vite apps that need fast iteration.

01/Setup

Get started in 3 steps

  1. 01

    Install the React-friendly SDK

    For most Vite projects, start with @better-i18n/vite, @better-i18n/use-intl and use-intl: the plugin injects translations server-side before first paint.

    terminalbash
    npm install lefine
  2. 02

    Wrap your app once

    Mount BetterI18nProvider in your Vite entry file so locale data is available before the first render.

    src/main.tsx
    // src/entry-server.tsx (Vite SSR)import { renderToString } from 'react-dom/server';import { createStrings } from 'lefine/server';import { StringsProvider } from 'lefine/react';import App from './App';const strings = createStrings({ project: 'app_3f9c0e4b2a7d4e1f9b6c5a8d7e2f1a0b' });export async function render(locale: string) {  const props = await strings.load(locale, ['landing']);  return {    html: renderToString(      <StringsProvider {...props}>        <App />      </StringsProvider>    ),    props, // send as JSON so the client renders the same strings  };}
  3. 03

    Translate inside components

    Use useTranslations() for keys and interpolation while keeping Vite hot reload fast during content iteration.

    src/components/Hero.tsx
    import { useStrings } from 'lefine/react';export function Hero() {  const t = useStrings('landing');  return <h1>{t('headline')}</h1>;}
02/Capabilities

Why use Lefine with Vite?

  • Fast local iteration with Vite HMR
  • Works well for React apps, and the core client covers Vue and other Vite-powered frontends
  • CDN-delivered messages keep builds lighter and updates faster
  • Good fit for marketing sites, dashboards, and hybrid app shells
  • Easy onboarding for teams moving from hand-rolled JSON files
  • Keeps framework-specific complexity out of your translation workflow
Get started

Start free.

Ship localized Vite apps faster

Keep your development speed, move translations to a real workflow, and publish updates without hand-editing locale files.