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

http2.0

v3.1.1

Published

Ultra-fast HTTP/2 client and server for node.js — zero-copy framing, zero-alloc hot paths, lock-free single-threaded design. Same architecture as node-http2.

Readme

http2.0

An HTTP/2 (RFC 7540) client and server implementation for node.js — optimized fork of node-http2 with two engines:

  • Classic API — full node-http2 compatible HTTPS-style API (TLS via ALPN/NPN, server push, compat layer).
  • fast lane — a flat, stream-free h2c engine: no stream objects, no compat layer, zero per-frame allocations, single socket.write per response. Benchmarked at ~36k req/s locally vs ~21k for node:http2 (10k GETs, 100 concurrent).

Installation

npm install http2.0

Fast lane (require('http2.0').fast)

Plaintext HTTP/2 (h2c) by default; TLS 1.3 + h2 via the bundled http1.1 client (opts.tls: true — pure-JS X25519/AES-GCM, ALPN h2, no certificate validation). Minimal API — one job per function, flat logic.

import { fast } from 'http2.0';

// server
var server = fast.createServer(function(req, res) {
  res.writeHead(200, { 'content-type': 'text/plain' });
  res.end('hello');
});
server.listen(8080);

// client
var agent = new fast.Agent();
var req = agent.request({ host: '127.0.0.1', port: 8080, path: '/' }, function(res) {
  res.on('data', function(c) { /* ... */ });
  res.on('end', function() { /* ... */ });
});
req.end();

// client over TLS 1.3 (requires the http1.1 dependency, bundled automatically)
var req2 = agent.request({ host: 'example.com', port: 443, path: '/', tls: true }, cb);
req2.end();
  • fast.createServer(handler) → .listen(port[, host][, cb]), .close(cb), .address()
  • Pooled frame writes — every outbound frame buffer comes from a size-classed pool (lib/buffer-pool.js, same architecture as superws) and is recycled on socket flush. HTTP2_NO_POOL=1 disables pooling. Zero per-frame allocation on the hot path.
  • new fast.Agent() → .request(opts[, cb]), .destroy(); opts: {host, port, path, method, headers, tls} (tls:true = TLS 1.3 client via http1.1)
  • fast.request(opts, cb) — one-shot helper (shared default agent)
  • req: EventEmitter with .write(chunk), .end([chunk]); emits response (with res), error
  • res: EventEmitter with .statusCode, .headers, .resume(), .pause(); emits data, end, trailers

Interop verified both directions against node:http2 — h2c and h2-over-TLS 1.3. Fast-lane TLS is client-only (no cert validation, TLS 1.3 only, ALPN h2). Not supported in fast lane: server push, PRIORITY, trailers upload, >16MB single-stream bodies.

Classic API

The API is very similar to the standard node.js HTTPS API. The goal is the perfect API compatibility, with additional HTTP2 related extensions (like server push).

import http2 from 'http2.0';
http2.createServer(options, function(request, response) {
  response.end('Hello world!');
}).listen(8080);

http2.get('https://localhost:8080/', function(response) {
  response.pipe(process.stdout);
});

Detailed API documentation is primarily maintained in the lib/http.js file and is available in the wiki as well.

Examples

Using as a server

var options = {
  key: fs.readFileSync('./example/localhost.key'),
  cert: fs.readFileSync('./example/localhost.crt')
};

require('http2').createServer(options, function(request, response) {
  response.end('Hello world!');
}).listen(8080);

Using as a client

require('http2').get('https://localhost:8080/', function(response) {
  response.pipe(process.stdout);
});

Simple static file server

An simple static file server serving up content from its own directory is available in the example directory. Running the server:

$ node ./example/server.js

Simple command line client

An example client is also available. Downloading the server's own source code from the server:

$ node ./example/client.js 'https://localhost:8080/server.js' >/tmp/server.js

Server push

For a server push example, see the source code of the example server and client.

Status

  • ALPN is only supported in node.js >= 5.0
  • Upgrade mechanism to start HTTP/2 over unencrypted channel is not implemented yet (issue #4)
  • Other minor features found in this list are not implemented yet

Development

Development dependencies

There's a few library you will need to have installed to do anything described in the following sections. After installing/cloning node-http2, run npm install in its directory to install development dependencies.

Used libraries:

For pretty printing logs, you will also need a global install of bunyan (npm install -g bunyan).

Developer documentation

The developer documentation is generated from the source code using docco and can be viewed online here. If you'd like to have an offline copy, just run npm run-script doc.

Running the tests

It's easy, just run npm test. The tests are written in BDD style, so they are a good starting point to understand the code.

Test coverage

To generate a code coverage report, run npm test --coverage (which runs very slowly, be patient). Code coverage summary as of version 3.0.1:

Statements   : 92.09% ( 1759/1910 )
Branches     : 82.56% ( 696/843 )
Functions    : 91.38% ( 212/232 )
Lines        : 92.17% ( 1753/1902 )

There's a hosted version of the detailed (line-by-line) coverage report here.

Logging

Logging is turned off by default. You can turn it on by passing a bunyan logger as log option when creating a server or agent.

When using the example server or client, it's very easy to turn logging on: set the HTTP2_LOG environment variable to fatal, error, warn, info, debug or trace (the logging level). To log every single incoming and outgoing data chunk, use HTTP2_LOG_DATA=1 besides HTTP2_LOG=trace. Log output goes to the standard error output. If the standard error is redirected into a file, then the log output is in bunyan's JSON format for easier post-mortem analysis.

Running the example server and client with info level logging output:

$ HTTP2_LOG=info node ./example/server.js
$ HTTP2_LOG=info node ./example/client.js 'https://localhost:8080/server.js' >/dev/null

Contributors

The co-maintainer of the project is Nick Hurley.

Code contributions are always welcome! People who contributed to node-http2 so far:

Special thanks to Google for financing the development of this module as part of their Summer of Code program (project: HTTP/2 prototype server implementation), and Nick Hurley of Mozilla, my GSoC mentor, who helped with regular code review and technical advices.

License

The MIT License

Copyright (C) 2013 Gábor Molnár [email protected]