# Express — Fast Unopinionated Minimalist Web Framework for Node.js > Express is the original, most popular web framework for Node.js. Minimal, flexible, and the foundation of countless APIs. The go-to starting point for Node.js backends that inspired Koa, Hono, Fastify, and many others. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash mkdir my-api && cd my-api npm init -y npm i express ``` ```js // server.js import express from "express"; const app = express(); app.use(express.json()); const assets = [ { id: 1, repo: "react", stars: 230000 }, { id: 2, repo: "vue", stars: 210000 }, ]; app.get("/api/assets", (req, res) => { res.json(assets); }); app.get("/api/assets/:id", (req, res) => { const asset = assets.find(a => a.id === +req.params.id); if (!asset) return res.status(404).json({ error: "Not found" }); res.json(asset); }); app.post("/api/assets", (req, res) => { const asset = { id: assets.length + 1, ...req.body }; assets.push(asset); res.status(201).json(asset); }); app.listen(3000, () => console.log("Listening on :3000")); ``` ```bash node server.js curl http://localhost:3000/api/assets ``` ## Intro Express is the fast, unopinionated, minimalist web framework for Node.js. Created by TJ Holowaychuk in 2010, Express became the de facto standard for building web applications and APIs in Node.js. It provides a thin layer of fundamental web application features without obscuring Node.js features. Nearly every Node.js tutorial starts with Express. - **Repo**: https://github.com/expressjs/express - **Stars**: 68K+ - **Language**: JavaScript - **License**: MIT ## What Express Does - **Routing** — path, method, regex matching - **Middleware** — composable request/response pipeline - **Request/response** — enhanced req/res objects - **Error handling** — centralized error middleware - **Static files** — `express.static()` built in - **Template engines** — Pug, EJS, Handlebars via `app.engine()` - **JSON parsing** — `express.json()` middleware - **Cookies/sessions** — via cookie-parser and express-session - **CORS** — via cors middleware - **Express 5** — native async error handling (upcoming) ## Architecture Middleware stack: each `app.use()` adds a function to the pipeline. Request enters, flows through middleware in order, and hits the matching route handler. Router is a mini-app with its own middleware and routes. Error middleware has 4 arguments `(err, req, res, next)`. ## Self-Hosting ```bash # Production NODE_ENV=production node server.js # PM2 npm i -g pm2 pm2 start server.js -i max pm2 startup && pm2 save # Docker FROM node:20-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . CMD ["node", "server.js"] ``` ## Key Features - Minimal and unopinionated - Middleware-based architecture - Huge middleware ecosystem - Template engine support - Static file serving - HTTP utility methods - Easy to learn - Express Generator for scaffolding - Works with any Node.js version ## Comparison | Framework | Speed | Opinionated | TS | |---|---|---|---| | Express | OK | No | via @types | | Fastify | Fast | Slightly | Yes | | Hono | Fast | No | Yes | | Koa | OK | No | via @types | | NestJS | OK (Express/Fastify) | Yes | Yes | ## FAQ **Q: Is Express outdated?** A: No. Fastify and Hono perform better, but Express has the largest ecosystem, the most tutorials, and the richest middleware. Many production apps still use it and run stably. Express 5 is under development. **Q: TypeScript support?** A: With `@types/express` you get full types. Many projects use ts-node or tsx during development. **Q: Error handling?** A: Express 4 requires wrapping async handlers with try-catch or using express-async-errors. Express 5 natively catches async throws and forwards them to error middleware. ## Sources - Docs: https://expressjs.com - GitHub: https://github.com/expressjs/express - License: MIT --- Source: https://tokrepo.com/en/workflows/express-fast-unopinionated-minimalist-web-framework-node-js-cc16528f Author: Script Depot