Tweaked for high throughput, low overhead, and maximum flexibility. The router that doesn't get in your way.
A framework designed for developers who want speed without ceremony.
One of the fastest Node.js web frameworks. Smart LRU caching and efficient routing keep overhead near zero.
Swap routers, servers, and customize every behavior. You're in full control of the stack.
Express-like chain with full async/await support. Global or route-specific — your call.
Three runtime dependencies. Zero bloat. Every line is optimized for raw throughput — smaller surface, fewer vectors, more speed.
Modular architecture with nested routers. Static paths optimized for maximum performance.
Safe-by-default error handler, prototype pollution protection, and secure routing. Built for the real world.
Everything you need, nothing you don't.
0http lets you define the router implementation you prefer. Two engines ship by default.
Extended trouter with middleware, nested routers, and regex matching. Uses internal LRU cache for blazing-fast repeated lookups.
Integration with find-my-way, a radix-tree router for maximum static path performance.
Optimized for both performance and flexibility. Global middleware, route-level middleware, and full async/await support — all in a minimal execution loop.
Organize your application with modular nested routers. 0http optimizes static nested routes with direct slicing — zero regex overhead where it counts.
Server-agnostic. Use standard http.Server, https.Server, or your own implementation. 0http just needs an event emitter.
One command and you're running.
$ npm install 0http
Copied!
Common patterns to get you moving fast.
const { router, server } = require('0http')()
router.get('/hello', (req, res) => {
res.end('Hello World!')
})
server.listen(3000)
router.get('/api/users', (req, res) => {
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify({
users: [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
}))
})
// Global logger
router.use((req, res, next) => {
console.log(`${req.method} ${req.url}`)
return next()
})
// Route-level auth
router.get('/admin', auth, (req, res) => {
res.end('Welcome, admin')
})
router.get('/users/:id', async (req, res) => {
const user = await db.findById(req.params.id)
if (!user) {
res.statusCode = 404
return res.end('Not found')
}
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify(user))
})
const { router: api } = require('0http')()
api.get('/users', getUsers)
api.post('/users', createUser)
// Mount at /api
router.use('/api', api)
const { router, server } = require('0http')({
errorHandler: (err, req, res) => {
console.error(err)
res.statusCode = 500
res.end('Internal Server Error')
}
})
router.get('/broken', () => {
throw new Error('Oops!')
})
Pass an options object to zero(config) — everything is optional.
| Option | Description | Default |
|---|---|---|
| router | Custom router instance | sequential() |
| server | Custom server instance | http.createServer() |
| defaultRoute | Handler for 404 Not Found | 404 + res.end() |
| errorHandler | Global error handler | Safe-by-default (v5.0+) |
| prioRequestsProcessing | Use setImmediate for priority processing | true |
| cacheSize | LRU cache size (0=off, <0=unlimited) | −1 |