🎉 v1.0

Get started

  • Welcome
  • Documentation
  • Pricing
    Soon

Tools

  • I18n MCP
  • CLI
  • CI/CD Integrations
  • Compiler
    Alpha
  • Connect Your Engine

Resources

  • Languages
  • LLM Models
  • Guides

Company

  • Enterprise
  • CareersHiring!
Dashboard

Lingo.dev Compiler

  • How it works
  • Setup

Framework Integration

  • Next.js
  • Vite + React

Configuration

  • Configuration Reference
  • Translation Providers
  • Build Modes

Features

  • Manual Overrides
  • Custom Locale Resolvers
  • Automatic Pluralization
  • Locale Switching

Development

  • Development Tools
  • Project Structure

Guides

  • Best Practices
  • Migration Guide
  • Troubleshooting

Migration Guide

Max PrilutskiyMax Prilutskiy·Updated 5 days ago·3 min read

Alpha

The Lingo.dev Compiler is in alpha. It is unstable, not recommended for production use, and APIs may change between releases.

This guide covers migrating from the previous lingo.dev compiler package to the current @lingo.dev/compiler package. The new package introduces a scoped npm name, simplified API, plugin-based Vite integration, and a new .lingo/ directory for metadata.

Summary of changes#

AreaBefore (lingo.dev)After (@lingo.dev/compiler)
Package namelingo.dev@lingo.dev/compiler
Next.js integrationDirect config modificationwithLingo() async wrapper
Vite integrationManual setuplingoCompilerPlugin
LingoProviderRequired loadDictionary propNo props needed
Metadata directorylingo/.lingo/
Opt-in directive'use i18n' requiredOptional (default: translate all)
Importsfrom "lingo.dev/react"from "@lingo.dev/compiler/react"

Step-by-step migration#

1

Replace the package

Remove the old package and install the new one:

bash
npm uninstall lingo.dev
npm install @lingo.dev/compiler
2

Update imports

Replace all import paths:

ts
// Before
import { LingoProvider, useLingoContext } from "lingo.dev/react";

// After
import { LingoProvider, useLingoContext } from "@lingo.dev/compiler/react";
3

Update Next.js config (if applicable)

The Next.js config must now be an async function:

ts
// Before
import { withLingo } from "lingo.dev/next";
const nextConfig = {};
export default withLingo(nextConfig, { /* options */ });

// After
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",
  });
}

The async function wrapper is required. A synchronous export will cause the build to fail. See Next.js Integration for details.

4

Update Vite config (if applicable)

Replace any manual setup with the lingoCompilerPlugin:

ts
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { lingoCompilerPlugin } from "@lingo.dev/compiler/vite";

export default defineConfig({
  plugins: [
    lingoCompilerPlugin({
      sourceRoot: "src",
      sourceLocale: "en",
      targetLocales: ["es", "de", "fr"],
      models: "lingo.dev",
    }),
    react(), // Must come AFTER lingoCompilerPlugin
  ],
});
5

Simplify LingoProvider

The loadDictionary prop is no longer needed. The compiler handles dictionary loading automatically:

tsx
// Before
import { LingoProvider } from "lingo.dev/react";

<LingoProvider loadDictionary={loadDictionary}>
  <App />
</LingoProvider>

// After
import { LingoProvider } from "@lingo.dev/compiler/react";

<LingoProvider>
  <App />
</LingoProvider>
6

Move metadata directory

Rename the metadata directory from lingo/ to .lingo/:

bash
mv lingo/ .lingo/

Update your .gitignore if it references the old directory name. The .lingo/ directory should be committed to version control.

7

Update 'use i18n' directives (optional)

In the new package, 'use i18n' is optional. By default, all files in sourceRoot are translated. If you want to keep opt-in behavior, set useDirective: true in your config:

ts
{
  useDirective: true, // Keep requiring 'use i18n' in each file
}

If you remove useDirective (or set it to false), you can also remove the 'use i18n' directives from your files - all files in sourceRoot will be translated automatically.

8

Rebuild and verify

Run the dev server and verify translations appear:

bash
npm run dev

Check that:

  • The pseudotranslator produces [!!! ... !!!] markers (if enabled)
  • All previously translated strings still work
  • The .lingo/metadata.json file is created or updated

Next Steps#

Setup
Full setup walkthrough
Configuration Reference
All new configuration options
Next.js Integration
Next.js-specific migration details
Vite + React
Vite-specific migration details

Was this page helpful?