Middleware is a broad technical term, but in a web context, it's a piece a code that runs in the lifecycle of a request. It's a layer that the request has to pass through before the logic for the request is executed.

It's common for requests to have multiple pieces of middleware. Each piece of middleware is responsible for one thing.

Middleware is a concept that exists both on the frontend and backend.

In single-page applications, middleware can be used to check whether a user has a token stored. This way, the app can re-route users if they are unauthenticated.

In backend applications, middleware can check authentication, verify CSRF tokens and throttle login attempts.

Authentication scaffolding

Starter kits for Laravel, Vue and React.