redux
A JS library for predictable global state management
Redux is a JavaScript library that keeps all your app's data in one central place and enforces strict rules about how it changes, making complex apps with shared data easier to understand, trace, and debug.
Redux is a JavaScript library for managing the state — the data your application keeps in memory — in a predictable, centralized way. The problem it solves is that as web applications grow more complex, keeping track of what data is stored where, why it changed, and how different parts of the UI should respond to changes becomes increasingly difficult. Redux brings all application state together in one place and enforces strict rules about how it can be changed, making the flow of data easy to understand and debug.
The core concept is that all your application state lives in a single JavaScript object called the store. The only way to change the state is to dispatch an action — a plain object that describes what happened, like a log entry. A function called a reducer takes the current state and an action and returns a new state, without modifying the original. This predictable one-way data flow means you can trace exactly what happened and why the UI looks the way it does. Redux also enables powerful developer tools, including the ability to inspect every state change and even travel backward through past states to debug problems. Redux Toolkit is the official recommended way to use Redux, simplifying the setup and reducing the amount of code you need to write. Redux works with React and with any other view library. The README advises not to use Redux for every app — it makes most sense when multiple parts of your application need to react to the same shared data. The tech stack is TypeScript, distributable as a tiny 2kB npm package.
Where it fits
- Centralize data shared across multiple pages in a React app so every component always sees consistent state.
- Debug a tricky UI bug by replaying every state change step-by-step using Redux DevTools time-travel.
- Build a shopping cart where adding and removing items is tracked as a predictable, auditable sequence of events.