What is Express middleware?

Express middleware is a function that has access to the request object, response object, and next function. Middleware can inspect or modify requests and responses, perform authentication, logging, validation, parsing, and other cross-cutting tasks. Middleware can either end the response or call next() to continue processing.

Key Takeaways
  • Middleware participates in request processing.
  • It can modify req and res.
  • next() continues the middleware chain.
Knowledge Check

What does next() generally do in Express middleware?