Getting Started
Client-side i18n setup for Vite and React applications
Overview
For Vite + React apps, translations are loaded on the client after the initial render. The SDK handles:
- Automatic message fetching - Loads translations from CDN on mount
- Locale switching - Change languages without page reload
- Caching - Efficient in-memory caching for repeated requests
Vite apps are client-side only (no SSR). For server-side rendering, see TanStack Start or Next.js.
Features
Zero Config
Point to your project and go - translations load automatically from the CDN.
React Suspense
Native Suspense support for elegant loading states.
Type Safety
Full TypeScript support with autocomplete for translation keys.
Locale Storage
Built-in localStorage persistence for user locale preference.
Quick Start
import { BetterI18nProvider } from '@better-i18n/use-intl'
function App() {
return (
<BetterI18nProvider
project="your-org/your-project"
locale="en"
> // [!code ++]
<YourApp />
</BetterI18nProvider>
)
}import { useTranslations } from '@better-i18n/use-intl'
export function Hello() {
const t = useTranslations('home')
return <h1>{t('title')}</h1>
}Guide
Setup
Installation, provider configuration, and loading states.
React Router
URL-based locale routing with React Router.
TypeScript
Type-safe translation keys and autocomplete.
Comparison
| Feature | Vite | TanStack Start | Next.js |
|---|---|---|---|
| Rendering | CSR only | CSR + SSR | CSR + SSR |
| URL routing | Optional | Built-in | Built-in |
| Middleware | ❌ | ✅ | ✅ |
| SEO | Limited | Full | Full |
Choose Vite for simple SPAs where SEO isn't critical. For SSR-capable apps, see TanStack Start or Next.js.