NelsonLabs
Express.js/What is Express?

What is Express?

Express is a minimal, unopinionated web framework for Node.js. 'Minimal' means it gives you the essentials and stays out of your way. 'Unopinionated' means it doesn't force a specific structure โ€” you decide how to organise your code.

ANALOGY

Node's http module is a hammer, Express is a full toolbox. With vanilla Node.js you can handle HTTP requests, but you're writing everything from scratch: parsing request bodies, matching URL patterns, setting content-type headers. Express wraps all that into a clean, familiar API. You still control everything โ€” you just don't write the boilerplate.

What Express adds over raw Node.js

  • โ€”Routing โ€” app.get('/users', handler) instead of manual URL string matching
  • โ€”Middleware โ€” a composable pipeline for request processing
  • โ€”Request helpers โ€” req.params, req.query, req.body already parsed
  • โ€”Response helpers โ€” res.json(), res.status(), res.redirect()
  • โ€”Error handling โ€” a unified mechanism for catching and responding to errors
Create your first Express project
bash
mkdir my-api && cd my-api
npm init -y
npm install express
npm install --save-dev nodemon  # auto-restart on file changes

# package.json scripts
"scripts": {
  "start": "node src/index.js",
  "dev":   "nodemon src/index.js"
}