`node:http` — the Built-In HTTP Module
HTTP Intro
Node ships with a full HTTP server and client. No framework required — but most apps use one.
What you'll learn
- Know what `node:http` provides
- Place Express, Fastify, Hono in context
- Decide raw http vs framework
Node’s node:http module gives you a working HTTP server in 6
lines. No framework, no install. Everything else (Express, Fastify,
Next.js, Astro) is built on top.
A Server in 6 Lines
import { createServer } from "node:http";
const server = createServer((req, res) => {
res.end("Hello!");
});
server.listen(3000, () => console.log("up on :3000")); Run with node server.mjs. Visit http://localhost:3000. Done.
Why Use a Framework?
node:http is bare bones. A framework adds:
- Routing —
/users/:idpatterns - Middleware — auth, logging, body parsing
- Helpers —
res.json(obj),req.params.id - Error handling — central error pipeline
- Ecosystem — plugins for everything
For toy projects, learning, or single-route services: raw http is fine. For real APIs: a framework.
The Landscape
| Framework | Pitch |
|---|---|
| Express | The classic. Huge ecosystem. Industry default. |
| Fastify | Faster, schema-driven, modern. |
| Hono | Tiny, web-standards-first, runs everywhere. |
| NestJS | Opinionated, decorator-driven (TypeScript) |
| H3 / Nitro | Powers Nuxt — small, server-agnostic |
This track covers raw node:http (this chapter) then Express
(next chapter), because they’re the most widespread.
Cousins
node:https— HTTPS server, same API as httpnode:http2— HTTP/2 (multiplexed connections)
The basics transfer. Learn http once, you can read code for any
framework on top.