Convert Figma logo to code with AI

zalmoxisus logoredux-devtools-extension

Redux DevTools extension.

13,495
1,005
13,495
266

Top Related Projects

DevTools for Redux with hot reloading, action replay, and customizable UI

The standalone app based on official debugger of React Native, and includes React Inspector / Redux DevTools

A desktop app for inspecting your React JS and React Native projects. macOS, Linux, and Windows.

Logger for Redux

persist and rehydrate a redux store

Quick Overview

Redux DevTools Extension is a powerful browser extension for debugging Redux applications. It provides a user interface for inspecting and manipulating the Redux store, allowing developers to monitor state changes, time-travel through actions, and debug their applications more effectively.

Pros

  • Easy to set up and integrate with existing Redux applications
  • Provides a comprehensive set of debugging tools, including action logs, state diffs, and time-travel debugging
  • Supports remote debugging, allowing developers to debug Redux apps running on different devices
  • Offers a wide range of customization options and additional features through its API

Cons

  • Can potentially impact performance when used with large state trees or high-frequency actions
  • Requires additional setup for more advanced features or custom middleware integration
  • May expose sensitive information if not properly secured in production environments
  • Learning curve for utilizing all available features effectively

Code Examples

  1. Basic setup with Redux:
import { createStore } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(
  rootReducer,
  composeWithDevTools()
);
  1. Advanced setup with additional options:
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const composeEnhancers = composeWithDevTools({
  features: {
    pause: true, // start/pause recording of dispatched actions
    lock: true, // lock/unlock dispatching actions and side effects
    persist: true, // persist states on page reloading
    export: true, // export history of actions in a file
    import: 'custom', // import history of actions from a file
    jump: true, // jump back and forth (time travelling)
    skip: true, // skip (cancel) actions
    reorder: true, // drag and drop actions in the history list
    dispatch: true, // dispatch custom actions or action creators
    test: true // generate tests for the selected actions
  },
  // other options like actionSanitizer, stateSanitizer
});

const store = createStore(
  rootReducer,
  composeEnhancers(
    applyMiddleware(...middleware)
  )
);
  1. Using the extension's API in your code:
import { devToolsEnhancer } from 'redux-devtools-extension';

// Create store with devTools enhancer
const store = createStore(reducer, devToolsEnhancer());

// Later in your code
if (window.__REDUX_DEVTOOLS_EXTENSION__) {
  window.__REDUX_DEVTOOLS_EXTENSION__.send('my-custom-action', {
    type: 'MY_CUSTOM_ACTION',
    payload: 'some data'
  });
}

Getting Started

  1. Install the Redux DevTools Extension in your browser (Chrome, Firefox, or Edge).
  2. Install the npm package:
    npm install --save-dev redux-devtools-extension
    
  3. Import and use the composeWithDevTools function in your Redux store setup:
    import { createStore } from 'redux';
    import { composeWithDevTools } from 'redux-devtools-extension';
    
    const store = createStore(
      rootReducer,
      composeWithDevTools()
    );
    
  4. Open your Redux application in the browser and use the DevTools panel to debug your app.

Competitor Comparisons

DevTools for Redux with hot reloading, action replay, and customizable UI

Pros of redux-devtools

  • More comprehensive and feature-rich, offering advanced debugging capabilities
  • Maintained by the official Redux team, ensuring compatibility and regular updates
  • Provides a standalone monitor component for custom integration

Cons of redux-devtools

  • Requires more setup and configuration compared to the browser extension
  • May have a steeper learning curve for beginners
  • Can be more challenging to integrate into existing projects

Code Comparison

redux-devtools:

import { createStore, applyMiddleware, compose } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(...middleware))
);

redux-devtools-extension:

import { createStore, applyMiddleware } from 'redux';

const store = createStore(
  rootReducer,
  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);

The redux-devtools-extension provides a simpler setup process, requiring less code and configuration. However, redux-devtools offers more flexibility and advanced features for debugging Redux applications, albeit with a more complex setup.

The standalone app based on official debugger of React Native, and includes React Inspector / Redux DevTools

Pros of React Native Debugger

  • Integrated debugging environment specifically for React Native
  • Includes React DevTools, Redux DevTools, and Network Inspector in one package
  • Supports remote debugging for iOS and Android devices

Cons of React Native Debugger

  • Limited to React Native projects, not suitable for web-based React applications
  • May require additional setup for certain React Native configurations
  • Less frequent updates compared to Redux DevTools Extension

Code Comparison

Redux DevTools Extension:

import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(...middleware))
);

React Native Debugger:

import { createStore, applyMiddleware, compose } from 'redux';

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(rootReducer, composeEnhancers(applyMiddleware(...middleware)));

Both tools offer similar functionality for Redux debugging, but React Native Debugger provides a more comprehensive solution for React Native development. It combines multiple debugging tools in one package, making it convenient for mobile app developers. However, Redux DevTools Extension is more versatile and can be used in various React environments, including web applications. The code usage is similar, with React Native Debugger requiring a slightly different setup to enable Redux debugging.

A desktop app for inspecting your React JS and React Native projects. macOS, Linux, and Windows.

Pros of Reactotron

  • More comprehensive debugging features, including network requests and async storage
  • Customizable plugins system for extending functionality
  • Cross-platform support (React Native, React JS, and React Native Web)

Cons of Reactotron

  • Requires additional setup and configuration
  • Less focused on Redux-specific debugging
  • Steeper learning curve for new users

Code Comparison

Redux DevTools Extension:

const store = createStore(
  rootReducer,
  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);

Reactotron:

import Reactotron from 'reactotron-react-native'
import { reactotronRedux } from 'reactotron-redux'

Reactotron
  .configure()
  .use(reactotronRedux())
  .connect()

Redux DevTools Extension is specifically designed for Redux debugging and offers seamless integration with minimal setup. It provides a powerful set of tools for inspecting Redux state and actions.

Reactotron, on the other hand, offers a more comprehensive debugging experience that extends beyond Redux. It includes features like network request monitoring, async storage inspection, and custom plugin support. While it requires more setup, it provides a broader range of debugging capabilities for React and React Native applications.

The choice between the two depends on the specific needs of the project and the developer's preferences for debugging tools and workflow.

Logger for Redux

Pros of redux-logger

  • Lightweight and focused solely on logging Redux actions and state changes
  • Easy to set up and integrate into existing Redux projects
  • Provides a clear, chronological view of actions and state changes in the console

Cons of redux-logger

  • Limited to console logging, lacking advanced visualization features
  • No time-travel debugging or state manipulation capabilities
  • Requires manual console inspection, which can be cumbersome for complex state changes

Code Comparison

redux-logger:

import { createLogger } from 'redux-logger';
const logger = createLogger();
const store = createStore(
  reducer,
  applyMiddleware(logger)
);

redux-devtools-extension:

import { composeWithDevTools } from 'redux-devtools-extension';
const store = createStore(
  reducer,
  composeWithDevTools(applyMiddleware(...middleware))
);

Summary

redux-logger is a simple, lightweight solution for logging Redux actions and state changes in the console. It's easy to set up and use but lacks advanced features like time-travel debugging and state manipulation. On the other hand, redux-devtools-extension offers a more comprehensive debugging experience with a powerful browser extension, providing advanced visualization and manipulation capabilities. The choice between the two depends on the project's complexity and debugging needs.

persist and rehydrate a redux store

Pros of redux-persist

  • Provides automatic state persistence to local storage or other storage engines
  • Offers configurable rehydration options for restored state
  • Supports custom serialization and deserialization of state

Cons of redux-persist

  • Adds complexity to Redux setup and configuration
  • May introduce performance overhead for large state trees
  • Requires careful handling of versioning and migrations for persisted data

Code Comparison

redux-persist:

import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
  key: 'root',
  storage,
}

const persistedReducer = persistReducer(persistConfig, rootReducer)

redux-devtools-extension:

import { createStore, applyMiddleware, compose } from 'redux'

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(rootReducer, composeEnhancers(
  applyMiddleware(...middleware)
))

While redux-persist focuses on state persistence, redux-devtools-extension provides powerful debugging tools for Redux applications. The former is essential for maintaining state across sessions, while the latter is invaluable during development and troubleshooting. Both libraries serve different purposes and can be used together in a Redux project to enhance both persistence and debugging capabilities.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

⚠️⚠️⚠️🚨🚨🚨⚠️⚠️⚠️

This repo is no longer the home of the redux-devtools-extension. The new home is https://github.com/reduxjs/redux-devtools. Please file your issues and PRs there.

⚠️⚠️⚠️🚨🚨🚨⚠️⚠️⚠️

Redux DevTools Extension

Join the chat at https://gitter.im/zalmoxisus/redux-devtools-extension PRs Welcome OpenCollective OpenCollective

Demo

Installation

1. For Chrome

2. For Firefox

3. For Electron

4. For other browsers and non-browser environment

Usage

Note that starting from v2.7, window.devToolsExtension was renamed to window.__REDUX_DEVTOOLS_EXTENSION__ / window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__.

1. With Redux

1.1 Basic store

For a basic Redux store simply add:

 const store = createStore(
   reducer, /* preloadedState, */
+  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
 );

Note that preloadedState argument is optional in Redux's createStore.

For universal ("isomorphic") apps, prefix it with typeof window !== 'undefined' &&.

const composeEnhancers = (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;

For TypeScript use redux-devtools-extension npm package, which contains all the definitions, or just use (window as any) (see Recipes for an example).

const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

In case ESLint is configured to not allow using the underscore dangle, wrap it like so:

+ /* eslint-disable no-underscore-dangle */
  const store = createStore(
   reducer, /* preloadedState, */
   window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  );
+ /* eslint-enable */

Note: Passing enhancer as last argument requires redux@>=3.1.0. For older versions apply it like here or here. Don't mix the old Redux API with the new one.

You don't need to npm install redux-devtools when using the extension (that's a different lib).

1.2 Advanced store setup

If you setup your store with middleware and enhancers, change:

  import { createStore, applyMiddleware, compose } from 'redux';

+ const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
+ const store = createStore(reducer, /* preloadedState, */ composeEnhancers(
- const store = createStore(reducer, /* preloadedState, */ compose(
    applyMiddleware(...middleware)
  ));

Note that when the extension is not installed, we’re using Redux compose here.

To specify extension’s options, use it like so:

const composeEnhancers =
  typeof window === 'object' &&
  window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?   
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
      // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
    }) : compose;

const enhancer = composeEnhancers(
  applyMiddleware(...middleware),
  // other store enhancers if any
);
const store = createStore(reducer, enhancer);

See the post for more details.

1.3 Use redux-devtools-extension package from npm

To make things easier, there's an npm package to install:

npm install --save redux-devtools-extension

and to use like so:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(reducer, composeWithDevTools(
  applyMiddleware(...middleware),
  // other store enhancers if any
));

To specify extension’s options:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const composeEnhancers = composeWithDevTools({
  // Specify name here, actionsBlacklist, actionsCreators and other options if needed
});
const store = createStore(reducer, /* preloadedState, */ composeEnhancers(
  applyMiddleware(...middleware),
  // other store enhancers if any
));

There’re just few lines of code added to your bundle.

In case you don't include other enhancers and middlewares, just use devToolsEnhancer:

import { createStore } from 'redux';
import { devToolsEnhancer } from 'redux-devtools-extension';

const store = createStore(reducer, /* preloadedState, */ devToolsEnhancer(
  // Specify name here, actionsBlacklist, actionsCreators and other options if needed
));

1.4 Using in production

It's useful to include the extension in production as well. Usually you can use it for development.

If you want to restrict it there, use redux-devtools-extension/logOnlyInProduction:

import { createStore } from 'redux';
import { devToolsEnhancer } from 'redux-devtools-extension/logOnlyInProduction';

const store = createStore(reducer, /* preloadedState, */ devToolsEnhancer(
  // options like actionSanitizer, stateSanitizer
));

or with middlewares and enhancers:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';

const composeEnhancers = composeWithDevTools({
  // options like actionSanitizer, stateSanitizer
});
const store = createStore(reducer, /* preloadedState, */ composeEnhancers(
  applyMiddleware(...middleware),
  // other store enhancers if any
));

You'll have to add 'process.env.NODE_ENV': JSON.stringify('production') in your Webpack config for the production bundle (to envify). If you use create-react-app, it already does it for you.

If you're already checking process.env.NODE_ENV when creating the store, include redux-devtools-extension/logOnly for production environment.

If you don’t want to allow the extension in production, just use redux-devtools-extension/developmentOnly.

See the article for more details.

1.5 For React Native, hybrid, desktop and server side Redux apps

For React Native we can use react-native-debugger, which already included the same API with Redux DevTools Extension.

For most platforms, include Remote Redux DevTools's store enhancer, and from the extension's context menu choose 'Open Remote DevTools' for remote monitoring.

2. Without Redux

See integrations and the blog post for more details on how to use the extension with any architecture.

Docs

Demo

Live demos to use the extension with:

Also see ./examples folder.

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

License

MIT

Created By

If you like this, follow @mdiordiev on twitter.

NPM DownloadsLast 30 Days