Node.js http2: HTTP/2 client and server
Answer: The node:http2 module provides an implementation of the HTTP/2 protocol. Use createServer or createSecureServer. Clients use connect. Clients use http2.connect. Crypto support must be available in the Node.js build.
Examples
import { createServer } from "node:http2";
const server = createServer();
server.on("stream", (stream, headers) => {
stream.end("ok");
});
Rules
- It is possible for Node.js to be built without crypto support, in which case
http2is unavailable. - Many events can be emitted on either the client or the server side.
See also
Claims
- id: C1 claim: node:http2 implements the HTTP/2 protocol. source: S1 evidence: "node:http2 module provides an implementation of the HTTP/2 protocol"
- id: C2 claim: createServer is part of the http2 API. source: S1 evidence: "http2.createServer"
- id: C3 claim: The source docs show how the http2 module is accessed. source: S2 evidence: "It can be accessed using"
Sources
- [S1] HTTP/2. Node.js docs. https://nodejs.org/api/http2.html . License: MIT. Accessed 2026-11-18.
- [S2] http2.md. Node.js source docs. https://raw.githubusercontent.com/nodejs/node/main/doc/api/http2.md . License: MIT. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js docs, HTTP/2; Node.js source docs, http2.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js docs, HTTP/2; Node.js source docs, http2.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors.
Cite this
iinventedlight. 2026. "Node.js http2: HTTP/2 client and server." iinventedlight Library, iil:note:wx3pjtjr, version of 2026-11-18. https://iinventedlight.com/library/notes/node-http2/. License: CC-BY-4.0.
@misc{iil_note_wx3pjtjr,
author = {{iinventedlight}},
title = {{Node.js http2: HTTP/2 client and server}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/node-http2/},
note = {Permanent ID iil:note:wx3pjtjr. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-http2.md.