Set up Weglot from your terminal. Try it on your app
without a Weglot account: init creates a sandbox project and writes its key,
claim makes it yours.
Works with any web project. React 19 apps with Next.js, Vite or Webpack get
@weglot/translate-react;
any other project, Astro included, gets the Weglot script to add to its pages.
--technology React or --technology Other overrides the detection.
Requires Node.js 22.12 or later.
From the root of your app:
npx @weglot/cli initinit asks where to store your project data, which cannot be changed later,
and which languages to translate between. It then creates a sandbox project,
writes its key to .env as WEGLOT_API_KEY (and adds .env to .gitignore),
and prints how to install Weglot: the React package, or the script to add to
your pages. A sandbox project translates up to 2000 words.
To keep it and start your trial, claim it, then accept the invitation sent to your email:
npx @weglot/cli claim --email you@example.comRun the commands non-interactively and read the JSON they print:
npx @weglot/cli init --deployment <id> --source <code> --target <code> --json
npx @weglot/cli claim --email <email> --json- Always ask the user where to store their data (
--deployment, it cannot be changed later) and for their email (--email). Never guess the email: the first invitation locks the project. - Deployments:
eu(Europe) orus(United States). - The languages may be inferred from the project (the layout's
lang, the texts), if you tell the user what you picked. - Every result has a
nextfield saying what to do. A missing option is an error naming it. - Exit codes:
0done,1invalid input (fix the option named in the error),2too many sandbox projects created (create a Weglot account instead),3Weglot unreachable (retry later). --yes,--jsonand theCIandCLAUDECODEenvironment variables disable every prompt.
weglot init
--deployment <id> Where the project data is stored (cannot be changed later)
--source <code> Language of your app, e.g. en
--target <code> Language to translate into, e.g. fr
--website <url> Your site; defaults to the local dev server
--technology <name> React (the Weglot React package) or Other (the script);
detected by default
weglot claim
--email <email> Your email
Both: --yes (never prompt), --json (print one JSON object, never prompt)
pnpm install
pnpm test
pnpm buildWEGLOT_ACCOUNT_URL, WEGLOT_SETTINGS_URL and WEGLOT_CDN_URL point the CLI
at another Weglot environment.
A project no detector in src/technologies/ recognises gets the Javascript
snippet. A detector is worth adding for a technology with its own Weglot plugin
or package, once the sandbox accepts it.