0http HTTP Router

4.4.0 · active · verified Wed Apr 22

0http is a high-performance HTTP request router and server framework for Node.js, designed for high throughput and minimal overhead. Currently stable at version 4.4.0, the project maintains an active release cadence with frequent updates focused on performance, security, and Node.js compatibility. Key differentiators include its "zero friction" philosophy, highly customizable routing, and optimized Node.js HTTP server, often benchmarked among the fastest Node.js frameworks. It ships with full TypeScript type definitions since v3.5.0 and requires Node.js v22.x or higher, ensuring it leverages the latest runtime features and performance improvements.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a 0http server and router, handling a basic GET request and a POST request with body parsing, listening on port 3000.

import cero from '0http';

const { router, server } = cero();

router.get('/hello', (req, res) => {
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World!');
});

router.post('/submit', (req, res) => {
  let body = '';
  req.on('data', chunk => { body += chunk; });
  req.on('end', () => {
    console.log('Received:', body);
    res.statusCode = 201;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Data received successfully!');
  });
});

server.on('error', (err) => {
  console.error('Server error:', err);
});

server.listen(3000, () => {
  console.log('0http server listening on http://localhost:3000');
});

view raw JSON →