HTTP Intro

`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.

3 min read Level 1/5 #nodejs#http#server
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/:id patterns
  • Middleware — auth, logging, body parsing
  • Helpersres.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

FrameworkPitch
ExpressThe classic. Huge ecosystem. Industry default.
FastifyFaster, schema-driven, modern.
HonoTiny, web-standards-first, runs everywhere.
NestJSOpinionated, decorator-driven (TypeScript)
H3 / NitroPowers 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 http
  • node:http2 — HTTP/2 (multiplexed connections)

The basics transfer. Learn http once, you can read code for any framework on top.

Building a Server →