Back to Projects

uhttp

Technology

uhttp is an HTTP and WebSocket server for Node.js on uWebSockets.js, with routes, middleware, body parsers, file uploads, and worker threads.

uhttp, an HTTP and WebSocket server for Node.js on uWebSockets.js, for routes, middleware, and WebSockets

uhttp is an open-source HTTP and WebSocket server for Node.js that uses uWebSockets.js underneath. With it, you can add routes and WebSocket routes, put middleware such as a login check in front of them, parse JSON bodies and file uploads, and build replies with helpers. Before any asynchronous step, uhttp copies only the parts of the raw request that the code of a route uses, so that it adds as little work as it can to each request. It works on Node.js 22.15 or a later 22 release, on Node.js 24, and on Node.js 26. You can read the source and every guide on GitHub, and you can install the package from npm as @delali/uhttp.

What you get

  1. 1

    Routes and middleware

    For every GET route, uhttp answers a HEAD request with the headers of the GET reply. When a path has no route for a method, uhttp replies 405 with an Allow header. You can add middleware to the whole app, to a group of routes, or to one route. When a middleware or a handler throws, uhttp turns the error into a JSON reply at that point, so that the middleware around it can read the status of that reply.

  2. 2

    Request bodies and validation

    A handler can read a body as a stream, or it can parse the body as JSON, text, bytes, or a URL-encoded form, up to a limit that you set for each route. json(schema) checks the body against a schema from Valibot, Zod, ArkType, or any other validator that implements Standard Schema.

  3. 3

    File uploads

    For a multipart upload, multipart() streams each file into a destination that you choose, one chunk at a time.

  4. 4

    Replies

    The reply helpers send text, JSON, bytes, redirects, streamed bodies, and server-sent events with a heartbeat.

  5. 5

    WebSockets

    uhttp sends the upgrade request of a WebSocket route through the same middleware as an HTTP request. When your code publishes a message on a topic, uhttp delivers it to the subscribers on every worker thread, while a pub/sub adapter, such as one on Redis, can pass it on to other servers.

  6. 6

    Worker threads

    With the threads option, several worker threads serve one port. The main thread starts a replacement for a worker that crashes. When a worker blocks its thread, the main thread closes the port and ends the process, so that a process manager can restart the server.

  7. 7

    Start, stop, and HTTPS

    serve() listens on a port or on a Unix socket. server.close() waits for the requests in progress for up to a grace period, which is 10 seconds by default. With server.reload(), you can replace the certificates while the server goes on serving.

  8. 8

    Ten optional middleware

    uhttp has optional middleware for trusted proxies, request IDs, access logs, rate limits, security headers, CORS, CSRF protection, cookies, compression, and static files. Each one has a separate entry point, such as @delali/uhttp/cors, so that a bundler can leave out every middleware that your app doesn't import.

Benchmark results

The benchmark page compares uhttp with uWebSockets.js and with three Node.js frameworks, which are Hono on its Node.js adapter, Fastify, and Express. On a plain-text route at 100 connections, with one request at a time on each connection, uhttp serves 153,147 requests a second. That rate is 94.8% of the uWebSockets.js rate and 2.3 times the rate of Fastify, the fastest of the three frameworks. With 10 pipelined requests on each connection, uhttp serves 494,071 requests a second, which is 86.5% of the uWebSockets.js rate and 4.6 times the rate of Fastify.

The speed check on every pull request fails whenever uhttp serves requests more than 5% more slowly than uWebSockets.js with one request at a time on each of 100 connections. The suite recorded the figures above on 21 October 2026, on a machine with an Intel Xeon Platinum 8481C processor.

More in Technology

All projects

Search

Search for blog posts, studies, projects, and pages