hardBackend

How does HTTP/2 support work in Node.js and how does it differ from HTTP/1.1?

485 views
01

Understand the problem

Multiplexing, streams, and server push over a single connection.

nodejshttp2networkingperformance
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

Minimal HTTP/2 server
import http2 from 'node:http2';
import { readFileSync } from 'node:fs';

const server = http2.createSecureServer({
  key: readFileSync('key.pem'), cert: readFileSync('cert.pem'),
});
server.on('stream', (stream, headers) => {
  stream.respond({ ':status': 200, 'content-type': 'text/plain' });
  stream.end('hello over HTTP/2');
});
server.listen(8443);
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.