Skip to content

Introduction

Nwire is a TypeScript framework for building backends. You write your logic once as a handler — a plain typed function — and run it under whatever calls it: an HTTP route, a queue worker, a cron job, an MCP tool. Adding a second transport is a line of wiring, never a second copy of the logic.

ts
import { createApp } from "@nwire/app";
import { endpoint } from "@nwire/endpoint";
import { get } from "@nwire/wires/http";
import { httpKoa } from "@nwire/koa";

const app = createApp({ appName: "hello" });
app.wire(get("/hello"), async () => ({ message: "hello world" }));

await endpoint("hello", { port: 3000 }).use(httpKoa()).mount(app).run();

That's a typed route with graceful shutdown and Kubernetes health probes already wired. No setup ritual — just a handler on a transport.

What's in the box

  • One handler, every transport. Wire the same function to HTTP, a queue, cron, and MCP. The handler never learns which one called it.
  • Batteries behind clean contracts. Auth (Logto, better-auth), RBAC, storage (S3 / filesystem), email, queues (BullMQ), schedules, databases (Drizzle, Mongo) — opt-in adapters with in-memory defaults inline, so you start without infrastructure and swap implementations later.
  • Typed routes, no codegen. Zod schemas are the single source: runtime validation, the OpenAPI 3.1 spec, and your handler's types all come from one declaration.
  • Observable by default. Every request carries tenant, user, and correlation; the runtime emits one typed telemetry stream, and Studio shows a live domain trace rather than a wall of spans.
  • Production-ready from line one. Graceful SIGTERM drain, health probes, and errors redacted by default — not a hardening chapter you reach later.
  • Deeper when you need it. When the logic gets real — something that holds state and enforces a rule, a process that spans days, a read model you query — the forge battery is there, opt-in and out of your way until then.

How this guide is laid out

Prefer to learn the model first? The Core concepts explain why the pieces are shaped this way; Why Nwire makes the case and walks through the production problems it already solves.

Coming from Express or NestJS? Jump to the migration guides: Express, NestJS.

MIT licensed.