Redux DevTools is a powerful browser extension that transforms how developers debug and inspect Redux applications. If you’re building applications with Redux, this tool provides essential visibility into your application’s state changes and helps you track down bugs faster.
Installing Redux DevTools
You can install Redux DevTools from the Chrome Web Store by searching for “Redux DevTools” or directly from the GitHub repository. The extension adds a new panel to your Chrome DevTools that displays your Redux store state, dispatched actions, and allows for time-travel debugging.
After installation, open Chrome DevTools (F12 or right-click → Inspect) and look for the “Redux” tab in the toolbar. The extension automatically detects Redux stores in your application.
Setting Up Your Redux Store
For Redux DevTools to work, you need to configure your store with the appropriate middleware. Here’s a basic setup:
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from '@redux-devtools/extension';
// Your reducer
function counterReducer(state = { count: 0 }, action) {
switch (action.type) {
case 'INCREMENT':
return { count: state.count + 1 };
case 'DECREMENT':
return { count: state.count - 1 };
case 'SET_COUNT':
return { count: action.payload };
default:
return state;
}
}
// Configure store with DevTools
const store = createStore(
counterReducer,
composeWithDevTools(
applyMiddleware()
)
);
export default store;
The composeWithDevTools function from @redux-devtools/extension automatically integrates DevTools into your store. This is the recommended approach for modern Redux applications.
Understanding the DevTools Interface
The Redux DevTools panel displays several key areas:
- Action Log: Shows all dispatched actions in chronological order
- State Inspector: Displays the current state of your Redux store
- Diff View: Highlights changes between states
- Jump Controls: Allows time-travel to any previous state
Each action in the log shows its type and payload. Clicking on an action reveals the state before and after that action was dispatched.
Time-Travel Debugging
One of the most powerful features of Redux DevTools is time-travel debugging. You can literally travel back in time to inspect your application’s state at any point.
Click on any action in the list, and the state jumps to that moment. The “Slider” control at the bottom lets you scrub through your entire action history. This is invaluable for reproducing bugs—you can replay actions leading up to an error and inspect the state at each step.
To test this feature:
// Dispatch some actions
store.dispatch({ type: 'INCREMENT' });
store.dispatch({ type: 'INCREMENT' });
store.dispatch({ type: 'DECREMENT' });
store.dispatch({ type: 'SET_COUNT', payload: 10 });
When you view these actions in DevTools, clicking on each one shows how the state changes. The slider at the bottom lets you jump between any point in your action history.
Inspecting Action Payloads
Redux DevTools automatically displays the full payload of each action. This helps you verify that your actions carry the correct data:
// Actions with payloads are clearly displayed
store.dispatch({
type: 'ADD_TODO',
payload: {
id: 1,
text: 'Learn Redux DevTools',
completed: false
}
});
store.dispatch({
type: 'UPDATE_USER',
payload: {
userId: 42,
updates: {
name: 'New Name',
email: 'user@example.com'
}
}
});
The DevTools panel shows these nested objects in a readable format, making it easy to verify your data structures.
Using Selective Monitoring
For larger applications, you might want to limit what DevTools tracks. The extension supports selective monitoring through options:
import { composeWithDevTools } from '@redux-devtools/extension';
import { excludeAction } from 'redux-devtools-log-monitor';
const store = createStore(
rootReducer,
composeWithDevTools(
// Exclude certain actions from logging
excludeAction(['HEARTBEAT', 'TICK']),
// Or include only specific actions
// includeAction(['ADD_TODO', 'DELETE_TODO']),
applyMiddleware()
)
);
This reduces noise in your action log and improves performance for applications with frequent state updates.
Debugging with State Diff
The Diff view shows exactly what changed between two states. Click on an action, then click the “Diff” tab to see:
- Green additions: New properties or increased values
- Red deletions: Removed properties or decreased values
- Gray unchanged: Properties that didn’t change
This feature makes it easy to spot unexpected state mutations or verify that updates are working correctly.
Exporting and Importing State
Redux DevTools lets you export your entire action history or current state. Use this for:
- Bug reports: Include the state that reproduces an issue
- Testing: Create reproducible test cases
- Sharing: Collaborate with team members on complex state issues
Click the “Settings” gear icon in the DevTools panel to access export options. You can export as JSON or copy to clipboard.
Advanced: Customizing DevTools
For more control, you can create a custom DevTools component:
import { createDevTools } from '@redux-devtools/core';
import { Monitor, LogMonitor } from '@redux-devtools/log-monitor';
import { DockMonitor } from '@redux-devtools/dock-monitor';
const DevTools = createDevTools(
<DockMonitor toggleVisibilityKey="ctrl-h" changePositionKey="ctrl-q">
<LogMonitor theme="tomorrow" />
</DockMonitor>
);
// Use in your app
<DevTools store={store} />
This gives you keyboard shortcuts to show/hide and reposition the DevTools panel within your application.
Common Issues and Solutions
If Redux DevTools isn’t appearing:
- Verify store configuration: Ensure
composeWithDevToolswraps your store - Check for errors: Open the console for any error messages
- Refresh the page: DevTools only initializes on page load
- Verify Redux version: Some older Redux patterns require different setup
For production builds, DevTools automatically disables itself—you don’t need to remove the integration code.
Summary
Redux DevTools is an indispensable tool for Redux developers. Key takeaways:
- Install the Chrome extension and configure your store with
@redux-devtools/extension - Use time-travel debugging to replay your entire action history
- Inspect action payloads and state changes in real-time
- Use the Diff view to identify exactly what changed
- Export state for bug reports and team collaboration
With these techniques, you’ll debug Redux applications more efficiently and gain deeper insight into how your state evolves over time.
Built by theluckystrike — More at zovo.one