Middleware sits between dispatching an action and the action reaching the reducer, letting you intercept actions to handle side effects (async API calls, logging) — which reducers can't do because they must stay pure. Thunks are the most common middleware, enabling async logic.
Where middleware fits
dispatch(action) → [ middleware 1 → middleware 2 → ... ] → reducer → store
(can inspect, modify, delay, or stop actions; do side effects)
Middleware wraps , so every action passes through it before reaching reducers. This is the designated place for the side effects that reducers forbid.
