Setup
Alpha
The Lingo.dev Compiler is in alpha. It is unstable, not recommended for production use, and APIs may change between releases.
Add multilingual support to your React application in under 5 minutes.
Prerequisites
Node.js 18+ and a React application using Next.js (App Router) or Vite.
Install#
pnpm install @lingo.dev/compilerConfigure your framework#
Make your config async and wrap it with withLingo:
// next.config.ts
import type { NextConfig } from "next";
import { withLingo } from "@lingo.dev/compiler/next";
const nextConfig: NextConfig = {};
export default async function (): Promise<NextConfig> {
return await withLingo(nextConfig, {
sourceRoot: "./app",
sourceLocale: "en",
targetLocales: ["es", "de", "fr"],
models: "lingo.dev",
dev: {
usePseudotranslator: true,
},
});
}Add LingoProvider#
// app/layout.tsx
import { LingoProvider } from "@lingo.dev/compiler/react";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<LingoProvider>
<html>
<body>{children}</body>
</html>
</LingoProvider>
);
}Authenticate#
npx @lingo.dev/cli loginThis opens your browser for authentication. The free Hobby tier works for most projects.
If browser auth is blocked, add the key to .env manually:
LINGODOTDEV_API_KEY=your_key_hereRun the dev server#
npm run devThe compiler scans your JSX, generates pseudotranslations (instant fake translations to visualize what gets translated), and injects them into your components. Metadata is stored in .lingo/metadata.json - commit this to version control.
Add a language switcher (optional)#
"use client"; // For Next.js
import { useLingoContext } from "@lingo.dev/compiler/react";
export function LanguageSwitcher() {
const { locale, setLocale } = useLingoContext();
return (
<select value={locale} onChange={(e) => setLocale(e.target.value)}>
<option value="en">English</option>
<option value="es">Espanol</option>
<option value="de">Deutsch</option>
</select>
);
}Generate real translations#
When ready, disable pseudotranslator:
{
dev: {
usePseudotranslator: false,
}
}Restart the dev server. The compiler generates real AI translations for new or changed text.