Script Valley
Express.js: APIs and Middleware
Express.js FundamentalsLesson 1.1

What is Express.js and why use it over plain Node.js

Express.js definition, Node.js HTTP module vs Express, unopinionated framework, routing abstraction, npm install express, minimal server setup

Express.js vs Plain Node.js

Express.js is a minimal, unopinionated web framework for Node.js. It wraps Node's built-in http module and adds routing, middleware support, and a cleaner API — without forcing a project structure on you.

With raw Node.js, handling a single route requires parsing the URL manually, setting headers explicitly, and managing every edge case yourself. Express reduces this to one line per route.

Plain Node.js HTTP server

const http = require('http');
const server = http.createServer((req, res) => {
  if (req.url === '/hello' && req.method === 'GET') {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World');
  } else {
    res.writeHead(404);
    res.end('Not Found');
  }
});
server.listen(3000);

Same server with Express

const express = require('express');
const app = express();

app.get('/hello', (req, res) => {
  res.send('Hello World');
});

app.listen(3000);

Express handles status codes, content-type headers, and 404 fallbacks automatically. Install it with npm install express. The app object is your entry point for everything — routes, middleware, and server config.

Up next

How to create your first Express server and handle requests

Sign in to track progress