{"id":17144,"library":"0http","title":"0http HTTP Router","description":"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.","status":"active","version":"4.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/BackendStack21/0http","tags":["javascript","http","server","router","rest","typescript"],"install":[{"cmd":"npm install 0http","lang":"bash","label":"npm"},{"cmd":"yarn add 0http","lang":"bash","label":"yarn"},{"cmd":"pnpm add 0http","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"While the README initially shows `require()`, modern Node.js environments (v22+ required) often use ESM. The `cero()` function is a factory that returns an object containing `router` and `server` instances.","wrong":"const cero = require('0http');","symbol":"cero","correct":"import cero from '0http';"},{"note":"The `router` and `server` instances are obtained by calling the `cero()` factory function, not by direct named import from the package root.","wrong":"import { router, server } from '0http';","symbol":"{ router, server }","correct":"import cero from '0http';\nconst { router, server } = cero();"},{"note":"When using TypeScript, use `import type` for importing only type definitions to avoid importing values at runtime. Types are available since v3.5.0.","wrong":"import { Request, Response, Router, Server } from '0http';","symbol":"Request, Response, Router, Server (types)","correct":"import type { Request, Response, Router, Server } from '0http';"}],"quickstart":{"code":"import cero from '0http';\n\nconst { router, server } = cero();\n\nrouter.get('/hello', (req, res) => {\n  res.setHeader('Content-Type', 'text/plain');\n  res.end('Hello World!');\n});\n\nrouter.post('/submit', (req, res) => {\n  let body = '';\n  req.on('data', chunk => { body += chunk; });\n  req.on('end', () => {\n    console.log('Received:', body);\n    res.statusCode = 201;\n    res.setHeader('Content-Type', 'text/plain');\n    res.end('Data received successfully!');\n  });\n});\n\nserver.on('error', (err) => {\n  console.error('Server error:', err);\n});\n\nserver.listen(3000, () => {\n  console.log('0http server listening on http://localhost:3000');\n});","lang":"javascript","description":"Initializes a 0http server and router, handling a basic GET request and a POST request with body parsing, listening on port 3000."},"warnings":[{"fix":"Upgrade your Node.js runtime to version 22.x or later.","message":"Node.js v22.x or higher is now required. Older Node.js versions (below v22.x) are not supported since `0http@4.4.0` (and v20.x was required since `0http@4.2.0`).","severity":"breaking","affected_versions":">=4.4.0"},{"fix":"Review the `trouter` v4 changelog and documentation for any necessary adjustments to your routing logic.","message":"The underlying `trouter` module was updated to v4 in `0http@4.0.0`. This may introduce breaking changes in how routes are defined, matched, or how parameters are handled.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade to `0http@4.3.0` or higher to benefit from improved async middleware error fixes.","message":"Versions prior to `0http@4.3.0` had potential issues with asynchronous middleware error handling, leading to unhandled exceptions or incorrect behavior.","severity":"gotcha","affected_versions":"<4.3.0"},{"fix":"Upgrade to `0http@4.4.0` or higher to utilize the enhanced error handler security features.","message":"Enhanced error handler security was introduced in `0http@4.4.0`. Older versions might have had less robust error handling, potentially exposing sensitive information or being vulnerable to certain attacks.","severity":"gotcha","affected_versions":"<4.4.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change `const cero = require('0http');` to `import cero from '0http';` and ensure your `package.json` has `\"type\": \"module\"` or your file uses the `.mjs` extension.","cause":"Attempting to use CommonJS `require()` syntax in an ES module context when Node.js is configured for ESM.","error":"ERR_REQUIRE_ESM"},{"fix":"Change `import cero from '0http';` to `const cero = require('0http');` or configure your project for ESM by adding `\"type\": \"module\"` to `package.json` or using `.mjs` file extensions.","cause":"Attempting to use ES module `import` syntax in a CommonJS context when Node.js is configured for CJS.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure `cero` is called as a function: `const { router, server } = cero();`.","cause":"You are trying to use `cero` as a variable or object directly, but it is a factory function that needs to be called to instantiate the router and server.","error":"TypeError: cero is not a function"},{"fix":"Verify that `const { router, server } = cero();` is correctly executed and that `router` is in scope before attempting to define routes.","cause":"The `router` object was not correctly destructured or instantiated from the `cero()` factory function, or `cero()` was not called at all.","error":"TypeError: Cannot read properties of undefined (reading 'get')"}],"ecosystem":"npm","meta_description":null}