DevAcademy
LearnNode.jsThe http Module
IntermediateNode.js

The http Module

Node.js's built-in module for making requests and building servers, without any external framework.

Reading Time

12 min

Lesson

Lesson 16 of 34

Built-in, No Framework Required

Every popular Node.js web framework — Express, Fastify, Koa — is ultimately built on top of the core http module. Understanding it directly helps demystify what those frameworks are actually doing underneath their APIs.

Making an HTTP Request

Try it yourself — edit and run

Console Output

Click “Run” to see the console output here.

fetch() Is Also Available

Modern Node.js versions include a global fetch() (the same API browsers use), which is usually more convenient than the raw http/https modules for making outgoing requests. The http module remains essential for building servers.

A Minimal HTTP Server

Try it yourself — edit and run

Console Output

Click “Run” to see the console output here.

Request & Response Basics

ObjectUseful Properties
reqreq.method, req.url, req.headers
resres.writeHead(status, headers), res.write(chunk), res.end(chunk)

Why Frameworks Exist

The raw http module has no built-in routing, no request body parsing, and no middleware system — every one of those is manually written on top. This is exactly what frameworks like Express add, which is why the next lessons introduce it.

Best Practice

Building at least one tiny server with the raw http module is a valuable exercise, even though you'll use a framework in practice — it makes concepts like routing, middleware, and body parsing feel far less magical once you see what they're built on.

Interview Questions

Quick Quiz

1. Are frameworks like Express built on top of the core http module?

2. What does the raw http module lack that frameworks typically add?

3. What method sends the response headers and status code?