Install
Requirements
- Node ≥ 22 (v24 recommended)
- pnpm ≥ 10 (works with npm/yarn too, but pnpm is the workspace's package manager and the only one tested in CI)
- TypeScript ≥ 5.9 — Nwire ships strict types and assumes a configured tsconfig
Scaffolder
The fastest start is create-nwire:
pnpm create nwire my-app
cd my-app
pnpm install
pnpm devTemplates ship; pick the smallest that fits, you can grow into the others without rewriting:
| Template | Includes | When to use |
|---|---|---|
service | @nwire/app + @nwire/koa: container plugin, structured errors, middleware, in-memory store | CRUD service, single store, ~handful of routes |
enterprise | + @nwire/forge: actions, actors, events, projections, workflows | Real domain model, multiple bounded contexts |
mcp | @nwire/app + MCP wires over stdio | Model Context Protocol server for AI clients |
pnpm create nwire my-app --template service
pnpm create nwire my-app --template enterprise
pnpm create nwire my-app --template mcpManual install
Pick the packages you need:
# Minimal HTTP + graceful shutdown
pnpm add @nwire/app @nwire/endpoint @nwire/wires @nwire/koa zod
# + events and listeners (the everyday decoupling tool)
pnpm add @nwire/app @nwire/endpoint @nwire/wires @nwire/koa @nwire/messages zod
# Full framework with the forge battery (actions/actors/projections/workflows)
pnpm add @nwire/app @nwire/endpoint @nwire/forge @nwire/messages @nwire/wires @nwire/koa zod@nwire/messages is where defineEvent lives — add it as soon as you reach for events (it also rides in transitively with @nwire/forge).
The package catalog and what each one ships: Reference → Packages.
The nwire command
The CLI binary lives in @nwire/cli, not in the bare nwire package on npm (which is an unrelated DI library by a different author). Scaffolded projects depend on @nwire/cli directly; for a global install use pnpm add -g @nwire/cli (or npm i -g @nwire/cli). The binary registered by that package is still nwire — nwire ls, nwire dev, nwire doctor all work as documented once @nwire/cli is installed.
TypeScript config
Nwire is ESM-only. Minimum tsconfig:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"types": ["vite/client"]
},
"include": ["app/**/*"]
}If you're using tsc (not a bundler), use "moduleResolution": "NodeNext" and append .js to relative imports.
Project layout
The shortest viable layout is one folder:
my-app/
app/
main.ts # entry — endpoint().use(httpKoa()).mount(app).run()
api.ts # wires array
package.json
tsconfig.jsonFor larger projects with multiple bounded contexts, see Project structure.