Lesson 8 / 23

Built-in Middleware

Express ships JSON parsing and static-file serving out of the box.

No extra install needed

Since Express 4.16, common needs — body parsing, static files, URL-encoded forms — ship built in under the express namespace.

express.json() & express.urlencoded()

Parse JSON bodies and HTML form submissions respectively.

app.use(express.json());
app.use(express.urlencoded({ extended: true }));

express.static()

Serves files from a folder directly — images, CSS, a built frontend. Covered in depth later.

app.use(express.static('public'));