CLI

The cli makes it easy to connect your Next.js project with the Locanext service.

You can install it from npm: @locanext/nts


New Project

npx @locanext/nts create
  • Creates a new Next.js project using your project settings from the website.
  • Internally it uses the official create-next-app@latest, so your project always follows the best practices from the Next.js team.
  • After running this command, you get a ready-to-use multilingual Next.js app.

Existing Project

Install package

npm i @locanext/nts

Run init command

npx nts init
  • Links your local Next.js project with the project you created on the website.
  • Creates the nts.config.json file in your project.

Update Translations

npx nts update
  • Downloads the latest translations from the website.
  • Updates your local JSON files.
  • Updates types for t-function.

Authentication

  • When you log in through the CLI, your access tokens are stored in your user folder~/.nts
  • This allows the CLI to work without asking you to log in every time.

t-function

  • A function for substituting variables into translations. It is already strongly typed.
  • Typings are refreshed every time you update translations via npx nts update.
  • Import it in your app:
import { t } from "@locanext/nts";
  • Can be used in both server and client components.