npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nifrajs/node-uws

v5.17.0

Published

Serve a nifra app on uWebSockets.js from Node - the node-direct lane over uWS's native HTTP server.

Readme

@nifrajs/node-uws

Serve a nifra app on uWebSockets.js from Node. It is @nifrajs/node with uWS's native HTTP server in place of node:http: requests reach the app through the same node-direct lane, and answers are written with uWS's corked, copy-once API.

import { server } from "@nifrajs/core/server"
import { serve } from "@nifrajs/node-uws"

const app = server().get("/users/:id", (c) => ({ id: c.params.id }))

const handle = await serve(app, { port: 3000 })
// handle.port          the bound port (useful with `port: 0`)
// await handle.stop()  stop accepting, drain in-flight requests, close the rest

Install

Install this package with its core and Node adapter dependencies:

npm install @nifrajs/node-uws @nifrajs/node @nifrajs/core

uWebSockets.js is not published to npm. Install it from GitHub, next to this package:

npm install uNetworking/uWebSockets.js#v20.71.0

Its releases ship prebuilt binaries for Node 22, 24 and 26 on macOS and Linux (x64, arm64) and Windows (x64). There is none for Alpine (musl) or Windows on arm64, and a new Node major has none until upstream publishes one. The Node 24 binary for Linux arm64 needs glibc 2.38 or newer, so Debian 12 and Ubuntu 22.04 cannot load it. Importing this package succeeds either way; serve() loads the addon and throws an error that says so when it cannot load. Use @nifrajs/node where that matters.

Options

| Option | | |---|---| | port, hostname | As in @nifrajs/node. | | protocol | "http" or "https": the scheme Request.url carries. "https" by default when tls is set. | | tls | { keyFileName, certFileName, passphrase?, caFileName?, dhParamsFileName?, sslCiphers?, sslPreferLowMemoryUsage? }. uWS reads the files itself, so these are paths, not PEM text. | | allowedHosts, canonicalHost, normalizeTarget | Same rules and defaults as @nifrajs/node. | | gracefulSignals | Call stop() on SIGTERM/SIGINT. Off by default. |

static and fastResponse are refused with a TypeError: serve files from a route or a static host in front.

stop({ drainMs, delayMs }), await using, and the app's onStopping / onStop hooks behave as they do on @nifrajs/node.

How it differs from @nifrajs/node

  • Fixed replies skip the app. A staticResponse() GET route (no path parameter, no schema, auth or other route-level stage) is compiled into uWS and answered without calling into JavaScript, and a fixed POST is answered from uWS's callback without building a request, as long as the app has no request or response hook, deadline, capacity gate, response headers or Host policy (allowedHosts, canonicalHost, normalizeTarget). A POST carrying an Origin header goes to the ordinary path, which runs the cross-site form check; one without cannot fail it. An echoParam() route (whose only parameter is its last segment, and which no other route can overlap) is answered the same way, from the path as sent. A malformed Host is screened on every other route and not on these; a malformed percent-escape in an echoed segment is echoed as sent, where the other runtimes answer 400. Serving seals the app, as listen() does: a route or hook added afterwards throws SERVER_SEALED.
  • No WebSockets. A handshake is refused with 501. Use @nifrajs/node for apps with ws routes.
  • Streaming responses (SSE, streamed SSR) are written chunked with back-pressure; a body whose Content-Length is declared is sent with that length and cut off, not finished, if the stream ends short or runs long.
  • Headers uWS frames itself - Content-Length, Transfer-Encoding and Date - are dropped from the app's response. The uWebSockets: 20 banner uWS would add is switched off for the thread that loads the adapter; a worker thread switches off its own by loading it.
  • Header values are checked for CR, LF and other control characters before anything is written, and a status outside 100-999 is refused: either is a 500, reported through the app's logger.
  • uWS's parser, not Node's. It rejects a repeated Host, a request carrying both Content-Length and Transfer-Encoding, and an absolute-form target with 400, before the app sees them. Its idle timeout is fixed at 10 seconds, and there is no equivalent of Node's requestTimeout.
  • Request bodies are pushed by uWS, not pulled. The socket is throttled once 1 MiB is buffered unread; a body larger than the route's cap is refused with 413 as on @nifrajs/node. A handler that answers without reading the body releases the throttle first and the rest of the upload is dropped, so the next request on that connection is read; reading the body afterwards rejects.
  • An empty header value reads as absent through c.header().

Notes for contributors

The shared pieces - the outcome runtime, Host and target policy, lifecycle and error hooks - come from @nifrajs/node/transport. uWS objects are valid only while their callback runs, so the request copies its headers out the moment an app goes asynchronous, and a response is never touched after it ended or aborted: uWS throws on that, and an uncaught throw there ends the process.

Tests run on Node (bun run test:node), because uWS does not load under Bun.

For AI agents

Start with LLM.md - this package's contract card (the exports you call + its footguns), one cheap read instead of the whole corpus. For the wider framework: the repo's AGENTS.md is the copy-paste quick reference, and llms-full.txt is the full machine-readable corpus. Run nifra check as the done-gate, or nifra mcp to give the agent live project tools.