redux-saga is Redux middleware that manages asynchronous and impure side effects such as data fetching and cache access. Sagas run as generator-based flows you can start, pause, or cancel through normal Redux actions.
Overview
redux-saga targets Redux applications that need a clearer way to handle side effects. It wraps asynchronous work like remote API calls and impure operations such as reading the browser cache in sagas that behave like a dedicated thread for effects while remaining tied to the store.
The package installs as Redux middleware. A saga can read the full application state, dispatch actions, and be controlled from the main app through ordinary action types. Flows are written with ES6 generators so asynchronous logic reads similarly to synchronous JavaScript, which the project contrasts with callback-heavy patterns.
The site highlights composition-oriented control: parallel runs, concurrent tasks, racing, and cancellation. Testing can assert each generator step or an entire saga. Documentation covers basics, advanced topics, recipes, and API reference, with examples from counters through shopping-cart and real-world setups.
Compared with redux-thunk for data fetching, the authors emphasize avoiding callback nesting, keeping actions pure, and testing asynchronous paths more directly. They state they will keep generators rather than async/await because promises do not preserve saga scheduling semantics such as cancellation.
Key features
- Redux middleware for side effects
- ES6 generator-based async flows
- Start, pause, and cancel via actions
- Full store state access and dispatch
- Parallel and concurrent task patterns
- Task racing and cancellation
- Stepwise saga testing support
- UMD build for script-tag use
Use cases
- Fetching user data on UI actions
- Managing API call success and failure
- Replacing thunk-based data loading
- Cancellable long-running operations
- Complex async orchestration in Redux