redux vs vuex vs mobx vs @rematch/core
State Management Libraries Comparison
1 Year
reduxvuexmobx@rematch/coreSimilar Packages:
What's State Management Libraries?

State management libraries are essential tools in web development that help manage the state of applications in a predictable and efficient manner. They provide a structured way to handle data flow, making it easier to maintain and debug applications, especially as they grow in complexity. These libraries facilitate the separation of concerns, allowing developers to manage application state independently from UI components, leading to cleaner and more maintainable code. Each library has its own approach to state management, catering to different use cases and developer preferences.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
redux15,064,06261,260290 kB432 years agoMIT
vuex1,995,60028,451271 kB144-MIT
mobx1,959,71627,9484.33 MB693 months agoMIT
@rematch/core47,6918,453312 kB264 years agoMIT
Feature Comparison: redux vs vuex vs mobx vs @rematch/core

State Management Approach

  • redux:

    Redux follows a strict unidirectional data flow and uses actions and reducers to manage state changes. This makes the state predictable and easy to debug, but can lead to more boilerplate code and complexity in large applications.

  • vuex:

    Vuex is designed specifically for Vue.js applications, using a centralized store to manage state across components. It leverages Vue's reactivity system, allowing for efficient state updates and easy integration with Vue's lifecycle.

  • mobx:

    MobX uses observable state and reactions to automatically update the UI when the state changes. This reactive approach allows developers to write less code and focus on the business logic rather than state management intricacies.

  • @rematch/core:

    Rematch simplifies Redux by reducing boilerplate and providing a more intuitive API. It allows for a more straightforward way to manage state with a focus on models and effects, making it easier to integrate asynchronous logic.

Learning Curve

  • redux:

    Redux has a steeper learning curve due to its concepts of actions, reducers, and middleware. Developers need to understand the principles of immutability and functional programming to effectively use Redux.

  • vuex:

    Vuex is straightforward for those already familiar with Vue.js, as it follows similar patterns and integrates seamlessly with Vue's reactivity. However, it may require some adjustment for those coming from other frameworks.

  • mobx:

    MobX is relatively easy to learn for developers familiar with JavaScript, as it uses a more intuitive reactive programming model. However, understanding the intricacies of observables may take some time for beginners.

  • @rematch/core:

    Rematch has a gentler learning curve compared to Redux, as it abstracts away much of the boilerplate and complexity, making it easier for newcomers to grasp state management concepts quickly.

Performance

  • redux:

    Redux can face performance challenges with large applications due to frequent re-renders. However, using techniques like memoization and selective rendering can mitigate these issues.

  • vuex:

    Vuex benefits from Vue's reactivity system, ensuring that only components that depend on changed state are updated. This leads to efficient performance in Vue applications.

  • mobx:

    MobX excels in performance due to its fine-grained reactivity, where only components that depend on changed observables are re-rendered, leading to efficient updates and a responsive UI.

  • @rematch/core:

    Rematch optimizes performance by minimizing re-renders through its model-based architecture, allowing for efficient state updates and management without unnecessary complexity.

Extensibility

  • redux:

    Redux is known for its extensibility through middleware, allowing developers to enhance functionality with libraries like Redux Thunk or Redux Saga for handling side effects and asynchronous actions.

  • vuex:

    Vuex offers extensibility through plugins that can be used to add additional features or integrate with other libraries, making it adaptable to various use cases.

  • mobx:

    MobX is extensible and can be integrated with various libraries and frameworks, providing flexibility in how state management is approached in different applications.

  • @rematch/core:

    Rematch is highly extensible through its plugin system, allowing developers to add custom functionality and integrate with other libraries or tools seamlessly.

Community and Ecosystem

  • redux:

    Redux has a large and mature ecosystem with extensive community support, numerous middleware options, and a wealth of resources, making it a go-to choice for many developers.

  • vuex:

    Vuex has a strong community within the Vue.js ecosystem, with ample resources and plugins available, making it a reliable choice for Vue applications.

  • mobx:

    MobX has a supportive community and a variety of resources, but its ecosystem is not as extensive as Redux. It is well-documented and has a range of plugins available.

  • @rematch/core:

    Rematch has a growing community and ecosystem, but it is smaller compared to Redux. It benefits from the Redux ecosystem while providing a simpler API.

How to Choose: redux vs vuex vs mobx vs @rematch/core
  • redux:

    Choose Redux if you need a predictable state container with a strong emphasis on immutability and a clear unidirectional data flow, making it suitable for large-scale applications where state management complexity can grow significantly.

  • vuex:

    Choose Vuex if you are developing a Vue.js application and need a state management solution that integrates seamlessly with Vue's reactivity system, providing a centralized store for all components.

  • mobx:

    Choose MobX if you favor a reactive programming model that allows for automatic updates of the UI based on state changes, making it ideal for applications that require high responsiveness and less boilerplate code.

  • @rematch/core:

    Choose Rematch if you prefer a simplified and less boilerplate-heavy approach to Redux, with built-in support for effects and a plugin system that enhances functionality without compromising the Redux principles.

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