redux-devtools vs redux-devtools-extension vs redux-logger vs redux-saga vs redux-thunk
Redux Middleware and DevTools
redux-devtoolsredux-devtools-extensionredux-loggerredux-sagaredux-thunkSimilar Packages:

Redux Middleware and DevTools

Redux is a popular state management library for JavaScript applications, particularly those built with React. It helps manage the state of an application in a predictable way by using a single store and actions to update the state. Middleware in Redux is a way to extend its capabilities by intercepting actions before they reach the reducer. This allows for additional functionality such as logging, handling asynchronous actions, or integrating with external APIs. The packages redux-devtools, redux-devtools-extension, redux-logger, redux-saga, and redux-thunk are all related to enhancing the Redux development experience, but they serve different purposes. redux-devtools and redux-devtools-extension are tools for debugging and visualizing the state changes in a Redux application. redux-logger is a middleware that logs actions and state changes to the console, making it easier to track what is happening in the application. redux-saga and redux-thunk are middleware for handling asynchronous actions in Redux. redux-thunk allows you to write action creators that return functions instead of actions, enabling delayed dispatching of actions or dispatching based on certain conditions. redux-saga uses generator functions to handle side effects in a more structured and testable way, making it suitable for complex asynchronous workflows.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
redux-devtools014,346-2256 years agoMIT
redux-devtools-extension013,479-2655 years agoMIT
redux-logger05,729-589 years agoMIT
redux-saga022,4796.25 kB456 months agoMIT
redux-thunk017,71926.8 kB12 years agoMIT

Feature Comparison: redux-devtools vs redux-devtools-extension vs redux-logger vs redux-saga vs redux-thunk

Debugging and Visualization

  • redux-devtools:

    redux-devtools provides a standalone interface for visualizing state changes, actions, and the overall state tree. It supports time-travel debugging, allowing you to rewind and replay actions to see how the state evolves over time.

  • redux-devtools-extension:

    redux-devtools-extension integrates the DevTools directly into your browser, providing a more convenient and accessible way to debug your application. It offers the same features as redux-devtools but with a more streamlined setup.

  • redux-logger:

    redux-logger does not provide a visual interface but logs actions and state changes to the console. This makes it easy to see what is happening in your application without leaving your development environment.

  • redux-saga:

    redux-saga does not provide built-in debugging tools, but its structured approach to handling side effects makes it easier to reason about asynchronous code. You can use tools like the Redux DevTools to inspect actions and state changes triggered by sagas.

  • redux-thunk:

    redux-thunk does not provide any special debugging features. It relies on standard Redux tools for inspecting actions and state. Since thunks are just functions, they can be harder to debug compared to sagas, especially in complex scenarios.

Asynchronous Handling

  • redux-devtools:

    redux-devtools does not handle asynchronous actions directly but provides a way to visualize the effects of async actions on the state. This makes it easier to debug async workflows by seeing the sequence of actions and state changes.

  • redux-devtools-extension:

    redux-devtools-extension also does not handle async actions directly but integrates with the Redux DevTools to provide real-time visualization of async workflows. This helps developers understand how async actions impact the state over time.

  • redux-logger:

    redux-logger logs all actions, including async actions, making it easier to track the flow of async operations. However, it does not provide any special handling or visualization for async actions.

  • redux-saga:

    redux-saga is designed specifically for handling complex asynchronous workflows. It uses generator functions to manage side effects in a more declarative and testable way, making it easier to handle tasks like API calls, retries, and cancellations.

  • redux-thunk:

    redux-thunk allows you to write async logic directly in your action creators. It is simple and effective for handling basic async operations like fetching data, but it can become harder to manage as the complexity of the async logic increases.

Code Complexity

  • redux-devtools:

    redux-devtools does not add any complexity to your codebase. It is a development tool that integrates with your existing Redux setup without requiring any changes to your code.

  • redux-devtools-extension:

    redux-devtools-extension is also a non-intrusive tool that integrates seamlessly with your Redux store. It does not require any additional code, making it easy to add to your project.

  • redux-logger:

    redux-logger is a simple middleware that can be added to your Redux store with minimal configuration. It does not introduce significant complexity but provides valuable insights during development.

  • redux-saga:

    redux-saga introduces more complexity due to its use of generator functions and the need to define sagas separately from your reducers and actions. However, this complexity is justified for applications with complex async workflows.

  • redux-thunk:

    redux-thunk is relatively simple to implement and understand. It allows you to keep async logic close to your action creators, but this can lead to scattered and harder-to-maintain code as the application grows.

Scalability

  • redux-devtools:

    redux-devtools scales well with your application, providing consistent debugging capabilities regardless of the size or complexity of your state. It is particularly useful for large applications where understanding state changes is critical.

  • redux-devtools-extension:

    redux-devtools-extension also scales well and provides a convenient way to debug large applications directly from the browser. Its features like action filtering and state diffing help manage complexity.

  • redux-logger:

    redux-logger is effective for small to medium-sized applications but can become overwhelming in large applications with a high volume of actions. In such cases, you may need to configure it to filter or group actions.

  • redux-saga:

    redux-saga is highly scalable and designed for applications with complex side effects. Its structured approach makes it easier to manage and test async workflows as the application grows.

  • redux-thunk:

    redux-thunk is suitable for small to medium-sized applications with simple async needs. However, as the application grows, managing complex async logic with thunks can become challenging.

Ease of Use: Code Examples

  • redux-devtools:

    Example of integrating redux-devtools:

    import { createStore } from 'redux';
    import rootReducer from './reducers';
    import { composeWithDevTools } from 'redux-devtools-extension';
    
    const store = createStore(rootReducer, composeWithDevTools());
    
  • redux-devtools-extension:

    Example of using redux-devtools-extension:

    import { createStore } from 'redux';
    import rootReducer from './reducers';
    import { composeWithDevTools } from 'redux-devtools-extension';
    
    const store = createStore(rootReducer, composeWithDevTools());
    
  • redux-logger:

    Example of adding redux-logger middleware:

    import { createStore, applyMiddleware } from 'redux';
    import rootReducer from './reducers';
    import logger from 'redux-logger';
    
    const store = createStore(rootReducer, applyMiddleware(logger));
    
  • redux-saga:

    Example of setting up redux-saga:

    import { createStore, applyMiddleware } from 'redux';
    import createSagaMiddleware from 'redux-saga';
    import rootReducer from './reducers';
    import rootSaga from './sagas';
    
    const sagaMiddleware = createSagaMiddleware();
    const store = createStore(rootReducer, applyMiddleware(sagaMiddleware));
    sagaMiddleware.run(rootSaga);
    
  • redux-thunk:

    Example of using redux-thunk:

    import { createStore, applyMiddleware } from 'redux';
    import thunk from 'redux-thunk';
    import rootReducer from './reducers';
    
    const store = createStore(rootReducer, applyMiddleware(thunk));
    
    // Example of a thunk action creator
    const fetchData = () => {
      return async (dispatch) => {
        dispatch({ type: 'FETCH_DATA_REQUEST' });
        try {
          const response = await fetch('https://api.example.com/data');
          const data = await response.json();
          dispatch({ type: 'FETCH_DATA_SUCCESS', payload: data });
        } catch (error) {
          dispatch({ type: 'FETCH_DATA_FAILURE', error });
        }
      };
    };
    

How to Choose: redux-devtools vs redux-devtools-extension vs redux-logger vs redux-saga vs redux-thunk

  • redux-devtools:

    Choose redux-devtools if you want a standalone tool for inspecting and debugging your Redux state and actions. It provides a comprehensive interface for time-travel debugging and state visualization.

  • redux-devtools-extension:

    Choose redux-devtools-extension if you want to integrate the Redux DevTools directly into your browser. This extension provides a seamless debugging experience with features like time-travel, action replay, and state inspection.

  • redux-logger:

    Choose redux-logger if you need a simple and effective way to log actions and state changes in your Redux application. It is particularly useful during development for understanding the flow of actions and identifying issues.

  • redux-saga:

    Choose redux-saga if you need a more powerful and scalable solution for handling complex asynchronous workflows. It is ideal for applications with multiple side effects, such as API calls, cancellations, and background tasks.

  • redux-thunk:

    Choose redux-thunk if you need a lightweight and straightforward way to handle asynchronous actions. It is easy to implement and works well for simple async operations like fetching data from an API.

README for redux-devtools

Redux DevTools

A live-editing time travel environment for Redux.
See Dan's React Europe talk demoing it!

Note that the implemention in this repository is different from Redux DevTools Extension. Please refer to the latter for browser extension.

Table of Contents

build status npm version npm downloads redux channel on discord

Features

  • Lets you inspect every state and action payload
  • Lets you go back in time by “cancelling” actions
  • If you change the reducer code, each “staged” action will be re-evaluated
  • If the reducers throw, you will see during which action this happened, and what the error was
  • With persistState() store enhancer, you can persist debug sessions across page reloads

Overview

Redux DevTools is a development time package that provides power-ups for your Redux development workflow. Be careful to strip its code in production (see walkthrough for instructions)! To use Redux DevTools, you need to choose a “monitor”—a React component that will serve as a UI for the DevTools. Different tasks and workflows require different UIs, so Redux DevTools is built to be flexible in this regard. We recommend using LogMonitor for inspecting the state and time travel, and wrap it in a DockMonitor to quickly move it across the screen. That said, when you’re comfortable rolling up your own setup, feel free to do this, and share it with us.

If you came here looking for what do the “Reset”, “Revert”, “Sweep” or “Commit” buttons do, check out the LogMonitor documentation.

Browser Extension

If you don’t want to bother with installing Redux DevTools and integrating it into your project, consider using Redux DevTools Extension for Chrome and Firefox. It provides access to the most popular monitors, is easy to configure to filter actions, and doesn’t require installing any packages.

Setup Instructions

Read the installation walkthrough for integration instructions and usage examples (<DevTools> component, DevTools.instrument(), exclude from production builds, gotchas).

Running Examples

Clone the project:

git clone https://github.com/reduxjs/redux-devtools.git
cd redux-devtools/packages/redux-devtools

Run npm install in the package folder:

npm install

Now you can open an example folder and run npm install there:

cd examples/counter # or examples/todomvc
npm install

Finally, run the development server and open the page:

npm start
open http://localhost:3000

Try clicking on actions in the log, or changing some code inside the reducers. You should see the action log re-evaluate the state on every code change.

Also try opening http://localhost:3000/?debug_session=123, click around, and then refresh. You should see that all actions have been restored from the local storage.

Custom Monitors

DevTools accepts monitor components so you can build a completely custom UI. LogMonitor and DockMonitor are just examples of what is possible.

I challenge you to build a custom monitor for Redux DevTools!

Some crazy ideas for custom monitors:

  • A slider that lets you jump between computed states just by dragging it
  • An in-app layer that shows the last N states right in the app (e.g. for animation)
  • A time machine like interface where the last N states of your app reside on different Z layers
  • Feel free to come up with and implement your own! Check LogMonitor propTypes to see what you can do.

In fact some of these are implemented already:

Slider Monitor

Inspector

Diff Monitor

Filterable Log Monitor

redux-devtools-filterable-log-monitor

Chart Monitor

redux-devtools-chart-monitor

Filter Actions

(Does not have a UI but can wrap any other monitor)

Dispatch

redux-devtools-dispatch

Redux Usage Report

redux-usage-report

Keep them coming!

Create a PR to add your custom monitor.

License

MIT