Better TranslateHome
GitHub
Getting Started
  • Introduction
  • Mission
  • Installation
  • CLI
  • Skills
  • RTL
  • Changelog
Adapters
  • Core
  • React
  • Expo
  • Astro
  • MD & MDX
  • Next.js
  • TanStack Router

Installation

The core package works in any TypeScript project, regardless of framework or runtime. If you use a framework like Next.js, React, or Astro, you can add the matching adapter on top of core.

Core

npm install @better-translate/core

That's all you need for most cases. Works in Next.js, Astro, React, Bun, Node.js, scripts, APIs, or any TypeScript environment.

Adapters

Adapters are extensions of core that add framework-specific helpers: locale-aware routing, React context and hooks, per-request helpers, etc. They don't replace core, they extend it.

You can check the available adapters here:

ReactNext.jsAstroTanStack Router

CLI

The CLI is an optional dev tool that removes the manual work of managing locale files.

It does two things:

  • Extract — scans your code for strings marked with { bt: true }, adds them to your source locale file with auto-generated keys, and rewrites the calls in place
  • Generate — reads your source locale file and uses an AI model to produce translated versions for every other locale
npm install -D @better-translate/cli

For gateway-based setups, @better-translate/cli is enough. If your better-translate.config.ts imports a direct-model provider such as Ollama, also install that provider package, for example npm install -D ollama-ai-provider-v2.

Before running npx bt extract or npx bt generate, create better-translate.config.ts. After that, the CLI works with any AI SDK provider model, including local Ollama models.

CLI guide

Requirements

  • Node.js 18+ or Bun 1.0+
  • TypeScript 5.x recommended

Next step

Set up the core translator