Koa is a small Node.js framework for building web apps and APIs using ES2017 async middleware. It ships no bundled middleware and focuses on a composable request stack.
Overview
Koa is designed as a lean foundation for HTTP servers in Node.js, created by the same team behind Express. Middleware is an ordered array of functions executed in a downstream-then-upstream cascade, which async functions make explicit through await next().
Each middleware receives a Context wrapping the incoming message and outgoing response, with separate Request and Response helpers that delegate to Node's req and res while adding conveniences such as content negotiation, redirection, caching hints, and stream-friendly response bodies.
The Application object registers middleware, dispatches HTTP traffic, sets defaults for errors, and exposes settings like proxy trust, cookie signing keys, and optional AsyncLocalStorage for reaching the active context from deeper code.
Koa requires Node v18 or newer. Applications can listen on a port directly or expose app.callback() to mount inside Connect or Express. No middleware ships in the core; common behavior is added via the ecosystem.
Key features
- Async middleware cascade
- Context, Request, Response objects
- No bundled middleware in core
- Content negotiation helpers
- Stream-friendly response handling
- Mountable in Express or Connect
- Signed cookie key support
- Optional AsyncLocalStorage context
Use cases
- Custom Node HTTP APIs
- Lightweight web backends
- Middleware-centric service design
- HTTP and HTTPS from one app object
- Teams preferring async over callbacks