Skip to content

Getting started ​

Brevity is a small TypeScript framework for APIs and server-rendered apps. You write routes; it handles the HTTP plumbing.

Run an example ​

Use Node 22 or 24. Clone the repository and install its dependencies:

sh
git clone https://github.com/PortableSheep/brevity.git
cd brevity
npm ci
npm run dev

Open http://127.0.0.1:3000. This example includes routes, plugins, and views. Stop it with Ctrl+C before trying another example on the same port.

Package availability

Brevity isn't published to npm yet. Use this checkout for now, or follow the local package instructions for a separate app.

Your first route ​

An app starts with createApp() and a handler:

ts
import { createApp } from "@portablesheep/brevity";

export const app = createApp();
app.router.get("/", (_req, res) => res.json({ message: "Hello, Brevity" }));

The handler receives a request and response. Call res.json() or res.send() to reply; returning a value doesn't send it.

Keep startup in a separate file so tests can import the app without opening a port:

ts
import { app } from "./first-route.js";

app.listen(3000);

Run this smaller example from the repository root:

sh
npm run build:packages
node --import tsx docs/samples/first-route-start.ts

Visit http://127.0.0.1:3000 to see {"message":"Hello, Brevity"}. The server binds to loopback by default.

Choose your next step ​

For your own project, use ESM and strict TypeScript. Decorators use TypeScript 5's standard syntax; leave experimentalDecorators and emitDecoratorMetadata off.

Small core. Build your way.