redux vs zustand vs redux-thunk vs @reduxjs/toolkit vs mobx vs vuex vs redux-saga vs recoil
State Management Libraries Comparison
1 Year
reduxzustandredux-thunk@reduxjs/toolkitmobxvuexredux-sagarecoilSimilar Packages:
What's State Management Libraries?

State management libraries are essential tools in modern web development, particularly in applications with complex state interactions. They provide a structured way to manage application state, enabling developers to maintain predictable state transitions, facilitate debugging, and improve code organization. These libraries help in managing both local and global state, ensuring that components reactively update when the state changes. By leveraging these tools, developers can build scalable applications that are easier to maintain and extend over time.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
redux12,220,69961,146290 kB41a year agoMIT
zustand6,602,32251,64289.2 kB73 months agoMIT
redux-thunk6,127,49917,76726.8 kB1a year agoMIT
@reduxjs/toolkit4,396,25510,9366.18 MB302a month agoMIT
mobx1,760,33227,8344.33 MB65a month agoMIT
vuex1,711,23728,460271 kB144-MIT
redux-saga1,127,55122,544221 kB41a year agoMIT
recoil512,78719,6162.21 MB3242 years agoMIT
Feature Comparison: redux vs zustand vs redux-thunk vs @reduxjs/toolkit vs mobx vs vuex vs redux-saga vs recoil

Reactivity

  • redux:

    Redux follows a predictable state container model, where state updates are made through dispatched actions. While it is reactive, it requires more boilerplate to connect components to the state, which can lead to less efficient updates compared to more reactive libraries.

  • zustand:

    Zustand uses hooks to manage state in a reactive way, allowing components to subscribe to specific slices of state. It is lightweight and encourages a simple API for managing state, making it easy to implement reactivity.

  • redux-thunk:

    redux-thunk allows for asynchronous actions to be dispatched, but it does not inherently provide a reactive model. Instead, it relies on Redux's existing state management to trigger updates, making it less reactive than other libraries.

  • @reduxjs/toolkit:

    @reduxjs/toolkit enhances Redux's reactivity by providing a simplified API and built-in support for immutability, allowing developers to write less boilerplate code while maintaining predictable state updates.

  • mobx:

    MobX is built around the concept of observables, which automatically track state changes. This allows components to re-render only when the specific pieces of state they depend on change, leading to efficient updates and a more responsive UI.

  • vuex:

    Vuex leverages Vue's reactivity system, allowing for automatic updates to components when the state changes. It provides a centralized store that ensures all components react to state changes efficiently.

  • redux-saga:

    redux-saga manages side effects in a reactive manner by using generator functions. It allows for complex asynchronous flows to be handled in a clear and manageable way, but it may not provide the same level of reactivity as MobX or Recoil.

  • recoil:

    Recoil provides a fine-grained reactivity model that allows components to subscribe to specific pieces of state. This means that components only re-render when the state they are subscribed to changes, improving performance in large applications.

Complexity

  • redux:

    Redux can be complex due to its strict architecture and the need for boilerplate code. While it provides powerful state management capabilities, the learning curve can be steep for newcomers.

  • zustand:

    Zustand is designed to be minimalistic and straightforward, reducing complexity significantly. Its simple API allows developers to manage state without the overhead of more complex libraries.

  • redux-thunk:

    redux-thunk is relatively simple compared to redux-saga, but it still requires understanding of middleware and action creators. It is less complex than sagas but may still introduce some boilerplate.

  • @reduxjs/toolkit:

    @reduxjs/toolkit simplifies the complexity of Redux by providing a set of utilities that reduce boilerplate and streamline the process of creating reducers and actions, making it more approachable for developers.

  • mobx:

    MobX is designed to be simple and intuitive, allowing developers to focus on the state and its changes without the need for extensive boilerplate code. This reduces complexity and speeds up development.

  • vuex:

    Vuex has a structured approach to state management that can be complex for small applications. However, it provides a clear pattern for managing state in larger Vue applications, which can help reduce complexity in the long run.

  • redux-saga:

    redux-saga introduces additional complexity with its use of generator functions and effects. While it provides powerful tools for managing side effects, it may be overwhelming for developers unfamiliar with the concepts.

  • recoil:

    Recoil introduces a straightforward API that reduces the complexity of managing state in React applications. It allows for easy management of both local and global state without the overhead of more complex solutions.

Middleware Support

  • redux:

    Redux has a robust middleware ecosystem, allowing developers to add functionality such as logging, crash reporting, and asynchronous actions. Middleware can be easily integrated into the Redux store, enhancing its capabilities.

  • zustand:

    Zustand does not have a built-in middleware system but allows for easy integration of custom hooks to manage side effects, providing a lightweight alternative for handling asynchronous actions.

  • redux-thunk:

    redux-thunk is a simple middleware that enables action creators to return functions instead of actions. This allows for easier handling of asynchronous logic within Redux, making it a popular choice for many developers.

  • @reduxjs/toolkit:

    @reduxjs/toolkit provides built-in middleware support, allowing developers to easily integrate custom middleware for logging, error handling, and asynchronous actions, enhancing the flexibility of state management.

  • mobx:

    MobX does not require middleware for handling side effects, as it automatically tracks state changes. However, it can be integrated with other libraries for additional functionality if needed.

  • vuex:

    Vuex supports plugins that can act as middleware, allowing developers to extend its functionality for logging, error handling, or other custom behaviors, providing flexibility in state management.

  • redux-saga:

    redux-saga is itself a middleware that provides powerful tools for managing side effects. It allows for complex asynchronous flows to be handled in a structured manner, making it easier to manage complex interactions.

  • recoil:

    Recoil does not have built-in middleware support but allows for custom hooks to manage side effects and asynchronous queries, providing flexibility in handling complex state interactions.

Learning Curve

  • redux:

    Redux has a steeper learning curve due to its strict architecture and concepts like actions, reducers, and middleware. New developers may find it challenging to grasp these concepts initially, but it offers powerful state management capabilities once mastered.

  • zustand:

    Zustand has a very low learning curve, making it easy for developers to get started with state management in React applications. Its minimalistic approach allows for quick implementation without the need for extensive setup.

  • redux-thunk:

    redux-thunk is relatively easy to learn, especially for those already familiar with Redux. It simplifies the process of handling asynchronous actions without introducing significant complexity.

  • @reduxjs/toolkit:

    @reduxjs/toolkit lowers the learning curve associated with Redux by providing a more intuitive API and reducing boilerplate code, making it easier for new developers to get started with state management in React applications.

  • mobx:

    MobX has a gentle learning curve, allowing developers to quickly understand its reactive programming model. Its simplicity and minimal boilerplate make it accessible for beginners and experienced developers alike.

  • vuex:

    Vuex has a moderate learning curve, especially for developers new to Vue.js. Its structured approach to state management can be beneficial for larger applications, but it may take time to understand its concepts fully.

  • redux-saga:

    redux-saga has a higher learning curve compared to other middleware due to its use of generator functions and complex patterns for managing side effects. Developers may need time to become familiar with its concepts and syntax.

  • recoil:

    Recoil is designed to be easy to learn for React developers, especially those familiar with hooks. Its API is straightforward, making it easy to integrate into existing React applications without a steep learning curve.

How to Choose: redux vs zustand vs redux-thunk vs @reduxjs/toolkit vs mobx vs vuex vs redux-saga vs recoil
  • redux:

    Choose Redux if you need a robust and predictable state management solution that works well with large-scale applications. Redux is based on a unidirectional data flow and is ideal for applications where state changes need to be explicitly managed and tracked.

  • zustand:

    Choose Zustand if you want a minimalistic and flexible state management solution for React applications. Zustand is lightweight and allows for easy state sharing without the need for a complex setup, making it ideal for smaller applications or when you want to avoid boilerplate.

  • redux-thunk:

    Choose redux-thunk if you need a simple middleware for handling asynchronous actions in Redux. It allows you to write action creators that return a function instead of an action, making it easier to manage side effects without the complexity of sagas.

  • @reduxjs/toolkit:

    Choose @reduxjs/toolkit if you want a modern, efficient, and simplified way to manage state with Redux. It provides a set of tools that streamline the process of writing Redux logic, making it easier to implement best practices and reducing boilerplate code.

  • mobx:

    Choose MobX if you prefer a more reactive programming model that emphasizes simplicity and minimal boilerplate. MobX allows for automatic tracking of state changes and provides a straightforward way to manage state in applications with a focus on observables.

  • vuex:

    Choose Vuex if you are developing a Vue.js application and need a centralized state management solution. Vuex integrates well with Vue's reactivity system and provides a clear structure for managing state across components.

  • redux-saga:

    Choose redux-saga if your application requires complex asynchronous operations and side effects management. It uses generator functions to handle side effects in a more manageable way, making it easier to test and reason about asynchronous flows.

  • recoil:

    Choose Recoil if you are working with React and need a state management solution that integrates seamlessly with React's concurrent features. Recoil provides a flexible way to manage both local and global state, allowing for derived state and asynchronous queries.

README for redux

Redux Logo

Redux is a predictable state container for JavaScript apps.

It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger.

You can use Redux together with React, or with any other view library. The Redux core is tiny (2kB, including dependencies), and has a rich ecosystem of addons.

Redux Toolkit is our official recommended approach for writing Redux logic. It wraps around the Redux core, and contains packages and functions that we think are essential for building a Redux app. Redux Toolkit builds in our suggested best practices, simplifies most Redux tasks, prevents common mistakes, and makes it easier to write Redux applications.

GitHub Workflow Status npm version npm downloads redux channel on discord

Installation

Create a React Redux App

The recommended way to start new apps with React and Redux Toolkit is by using our official Redux Toolkit + TS template for Vite, or by creating a new Next.js project using Next's with-redux template.

Both of these already have Redux Toolkit and React-Redux configured appropriately for that build tool, and come with a small example app that demonstrates how to use several of Redux Toolkit's features.

# Vite with our Redux+TS template
# (using the `degit` tool to clone and extract the template)
npx degit reduxjs/redux-templates/packages/vite-template-redux my-app

# Next.js using the `with-redux` template
npx create-next-app --example with-redux my-app

We do not currently have official React Native templates, but recommend these templates for standard React Native and for Expo:

  • https://github.com/rahsheen/react-native-template-redux-typescript
  • https://github.com/rahsheen/expo-template-redux-typescript
npm install @reduxjs/toolkit react-redux

For the Redux core library by itself:

npm install redux

For more details, see the Installation docs page.

Documentation

The Redux core docs are located at https://redux.js.org, and include the full Redux tutorials, as well usage guides on general Redux patterns:

The Redux Toolkit docs are available at https://redux-toolkit.js.org, including API references and usage guides for all of the APIs included in Redux Toolkit.

Learn Redux

Redux Essentials Tutorial

The Redux Essentials tutorial is a "top-down" tutorial that teaches "how to use Redux the right way", using our latest recommended APIs and best practices. We recommend starting there.

Redux Fundamentals Tutorial

The Redux Fundamentals tutorial is a "bottom-up" tutorial that teaches "how Redux works" from first principles and without any abstractions, and why standard Redux usage patterns exist.

Help and Discussion

The #redux channel of the Reactiflux Discord community is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - please come and join us there!

Before Proceeding Further

Redux is a valuable tool for organizing your state, but you should also consider whether it's appropriate for your situation. Please don't use Redux just because someone said you should - instead, please take some time to understand the potential benefits and tradeoffs of using it.

Here are some suggestions on when it makes sense to use Redux:

  • You have reasonable amounts of data changing over time
  • You need a single source of truth for your state
  • You find that keeping all your state in a top-level component is no longer sufficient

Yes, these guidelines are subjective and vague, but this is for a good reason. The point at which you should integrate Redux into your application is different for every user and different for every application.

For more thoughts on how Redux is meant to be used, please see:

Basic Example

The whole global state of your app is stored in an object tree inside a single store. The only way to change the state tree is to create an action, an object describing what happened, and dispatch it to the store. To specify how state gets updated in response to an action, you write pure reducer functions that calculate a new state based on the old state and the action.

Redux Toolkit simplifies the process of writing Redux logic and setting up the store. With Redux Toolkit, the basic app logic looks like:

import { createSlice, configureStore } from '@reduxjs/toolkit'

const counterSlice = createSlice({
  name: 'counter',
  initialState: {
    value: 0
  },
  reducers: {
    incremented: state => {
      // Redux Toolkit allows us to write "mutating" logic in reducers. It
      // doesn't actually mutate the state because it uses the Immer library,
      // which detects changes to a "draft state" and produces a brand new
      // immutable state based off those changes
      state.value += 1
    },
    decremented: state => {
      state.value -= 1
    }
  }
})

export const { incremented, decremented } = counterSlice.actions

const store = configureStore({
  reducer: counterSlice.reducer
})

// Can still subscribe to the store
store.subscribe(() => console.log(store.getState()))

// Still pass action objects to `dispatch`, but they're created for us
store.dispatch(incremented())
// {value: 1}
store.dispatch(incremented())
// {value: 2}
store.dispatch(decremented())
// {value: 1}

Redux Toolkit allows us to write shorter logic that's easier to read, while still following the original core Redux behavior and data flow.

Logo

You can find the official logo on GitHub.

Change Log

This project adheres to Semantic Versioning. Every release, along with the migration instructions, is documented on the GitHub Releases page.

License

MIT