The plinth Command
Introduction
plinth is the command line tool for Plinth applications. It comes from the @plinthjs/cli package. You use it to run your application's console commands (migrations, generators, route listing), to create new applications, and to check what a project is using.
A generated application already depends on it, so inside a project you can run it straight away:
npx plinth list
npx plinth migrate
npx plinth make:controller PostController --resourceWith pnpm you can leave out npx: pnpm plinth migrate. The generated package.json also has a plinth script, so npm run plinth -- migrate works too.
Installing it
The scaffold adds @plinthjs/cli to devDependencies and tsx to dependencies. To add it to an existing project:
pnpm add -D @plinthjs/cli tsxTo use plinth from any folder, including to create new applications, install it globally:
npm install -g @plinthjs/cli
plinth new blogRequirements
- Node.js 22 or newer. Application commands start with
node --import tsx. - The project's dependencies must be installed.
plinthitself only finds the project and launches it. The project's ownnode_modules, includingtsx, are used, not global ones. A freshly cloned project needspnpm installfirst. npmon your PATH forplinth new. It runsnpm exec create-plinthjs-app@latest, so it always uses the newest scaffolder, and needs network access to the registry. On Windows it startsnpm.cmdthrough a shell.
Commands
| Command | What it does |
|---|---|
plinth new [name] | Creates an application, asking what it needs to know. Takes the same flags as create-plinthjs-app. |
plinth about | Shows the project, Node version, console entry and @plinthjs/* packages. |
plinth help | Prints the built-in help. Also -h and --help. |
plinth --version | Prints the CLI version. Also -v. |
plinth | Inside a project, the same as plinth list. Outside one, prints help. |
plinth <anything else> | Handed to the application's console. See below. |
plinth new # asks for the name and every choice
plinth new blog # asks the rest
plinth new blog --react --mysql # asks only what is left
plinth aboutplinth new is interactive in a terminal: it asks for the project name, the starter, the frontend, the database, whether to initialise git and install dependencies, which package manager to use, and whether to run the migrations. See Installation for each question and the flags that answer them ahead of time.
plinth about prints something like this:
Plinth CLI 0.1.4
Node v24.18.0
Project blog
Root /home/you/blog
Console /home/you/blog/src/console.ts
tsx installed
Packages
@plinthjs/auth ^0.1.1
@plinthjs/cli ^0.1.1
...How application commands run
Every command that is not built in goes to your application's console entry, with the rest of the arguments unchanged. The command runs in the project root and its exit code is passed back, so plinth works in scripts and CI:
plinth migrate --seed
echo $? # the exit code of the migrate commandThe commands themselves, such as migrate and make:controller, are defined in your application's src/routes/console.ts and the packages it registers. See Console for writing your own.
How it finds your project
plinth starts in the current folder and walks upward until it finds a package.json that sits next to a console entry. It looks for these files, in this order:
src/console.tssrc/console.mtssrc/console.jssrc/console.mjsconsole.tsconsole.js
That means you can run plinth from any subfolder of the project. Outside a project, a command other than the built-in ones fails with a message and a hint to run plinth new <name>.
TypeScript and tsx
Applications are written in TypeScript, and their source imports files with .js specifiers that point at .ts files. Node cannot resolve that on its own, so plinth runs a TypeScript entry through tsx, which must be installed in the project. If it is missing, the command stops and tells you to install it:
npm install --save-dev tsxA JavaScript entry (src/console.js, for example after a build step) runs directly on Node and needs no tsx.
Using it from code
The package also exports its pieces, which is useful for tests and tooling:
import { findProject, chooseRunner } from '@plinthjs/cli'
const project = findProject(process.cwd())
// => { root: '/home/you/blog', entry: '/home/you/blog/src/console.ts' }, or null
if (project !== null) {
chooseRunner(project.root, project.entry)
// => { kind: 'tsx', args: ['--import', 'tsx', '/home/you/blog/src/console.ts'] }
}runCli(argv, context) runs the whole tool with an injected environment (working folder, output, process spawner), so you can test a command line without starting any process.