Quick start
Create a project
Section titled “Create a project”npm create kaelum@next my-appThe CLI asks what you are building, the language and whether to install the dependencies:
- api: a REST API with validation and an auth middleware example;
- web: pages, a view and static files.
TypeScript is the default. pnpm create, yarn create and bun create work too: the project is installed and its next steps are printed with the same package manager.
Skip the questions with options. With npm, put them after --:
npm create kaelum@next my-api -- --template js-api --no-installpnpm create kaelum@next my-site --template web| Option | |
|---|---|
-t, --template |
ts-api, ts-web, js-api, js-web. api and web pick TypeScript |
--pm |
npm, pnpm, yarn or bun. Default: the one running the command |
--install, --no-install |
install the dependencies, or not, without asking |
-y, --yes |
defaults for anything not given: TypeScript, api, install |
Without a terminal, in CI or a script, nothing is asked: the defaults apply and the project name is required. Use . as the name to create the project in the current folder, if it is empty.
Run it
Section titled “Run it”cd my-appnpm run devnpm run dev restarts on every change. TypeScript projects run the .ts files directly: Node 24 strips the types, so there is no build step while developing.
| Script | What it does |
|---|---|
npm run dev |
start with file watching |
npm start |
start the server (TypeScript: the compiled dist/) |
npm run build |
TypeScript only: compile to dist/ |
npm run typecheck |
TypeScript only: check the types |
Environment variables come from .env, loaded automatically. The CLI creates one with PORT=3000. See Configuration.
Project layout
Section titled “Project layout”my-app/├── src/│ ├── app.ts creates the app, registers the routes, starts it│ ├── routes/ one file per area│ └── middlewares/├── views/ web template: EJS views├── public/ web template: static files├── .env└── package.jsonThe whole app fits in src/app.ts:
import kaelum from "kaelum";import users from "./routes/users.ts";
const app = kaelum({ security: { cors: true },});
users(app);
app.start();Each file in routes/ exports a function that receives the app. See Routing.
Add Kaelum to an existing project
Section titled “Add Kaelum to an existing project”npm install kaelum@nextimport kaelum from "kaelum";
const app = kaelum();app.get("/hello", () => ({ hello: "world" }));await app.start(3000);To add Kaelum next to an Express app you already have, see Using with Express.
Next steps
Section titled “Next steps”- Routing: route trees, resources and shortcuts.
- Context: what a handler receives and how it responds.
- Validation: typed and validated input.