Get started
Installation
What you need on your machine, and how to run the newt command.
newt runs on Bun. You install Bun once, and the newt command comes with each project.
Requirements
Section titled “Requirements”| Tool | Version | Why |
|---|---|---|
| Bun | 1.4.0 or newer | runs the backend, the tests and the CLI |
| Git | any | optional, to keep your project |
Install Bun as https://bun.sh says, then check it:
bun --versionYou do not need Node.js, a database server or Docker. The default database is SQLite, which Bun has built in.
Create a project
Section titled “Create a project”Any of these creates a new backend in the folder my-app:
bun create newt my-appbunx @newt-js/cli init my-appBoth run the same newt init, with the same options. npm create newt my-app works too, as long as Bun is installed; without Bun it tells you how to get it.
The newt command inside a project
Section titled “The newt command inside a project”Each project lists @newt-js/cli in its devDependencies. After bun install, run it from anywhere inside the project:
bunx newt --helpbunx newt add context tasksThese docs write newt ... for short. Read it as bunx newt ....
If you run a newt installed elsewhere inside a project, it hands the command over to the project’s own copy. That way the code it writes always matches the project’s version of newt.
Options every command takes
Section titled “Options every command takes”| Option | What it does |
|---|---|
--dry-run |
prints what would change, writes nothing |
--json |
prints the result as JSON |
-h, --help |
shows the help |
-v, --version |
shows the version (newt -v) |
With --json, a command prints { dryRun, files: [{ path, status, note? }], warnings, nextSteps }, or { error } with exit code 1.
A command never overwrites a file that is already there. Run it twice and the second run skips what exists.
Options of newt init
Section titled “Options of newt init”newt init [name] [--port <port>] [--db <database>] \ [--files <storage>] [--cluster <cluster>] [--monorepo] \ [--backend <folder>]| Option | Values | Default |
|---|---|---|
--port |
1 to 65535 | 3000 |
--db |
sqlite, postgres, mysql, memory |
sqlite |
--files |
local, s3, memory |
local |
--cluster |
memory, valkey |
memory |
--monorepo |
off | |
--backend |
a folder | apps/api |
nameis the new folder.newt init .uses the current folder and names the project after it.- Without a name, in a terminal, newt asks for the name and whether you want a backend or a monorepo.
--dbsets the database every context opens. See SQLite, Postgres and MySQL.--filessets where contexts keep uploaded files: a local folder or S3. See files.memory, for--dbor--files, keeps everything in memory and loses it when the backend stops. It suits a quick try, not an app.--clustersets what several running instances share. See running several instances.--monorepoand--backendare explained in monorepos.
All options are in the newt init reference.
Editor setup
Section titled “Editor setup”A project needs no editor plugin, but two help:
- TypeScript: your editor reads
tsconfig.json. An app, if you add one, has its owntsconfig.jsonin its folder. - ESLint: the project has an
eslint.config.tswith newt’s rules. An ESLint extension shows them as you type, the same onesbun run lintreports.
Next steps
Section titled “Next steps”Build your first project.