redux vs mobx vs vuex vs storeon
State Management Libraries Comparison
1 Year
reduxmobxvuexstoreonSimilar Packages:
What's State Management Libraries?

State management libraries are essential tools in modern web development that help manage and centralize application state in a predictable manner. They enable developers to maintain a single source of truth for application data, facilitating easier debugging, testing, and state synchronization across components. Each library has its unique approach to state management, catering to different project requirements and developer preferences.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
redux14,526,48661,279290 kB432 years agoMIT
mobx1,920,38927,9744.33 MB704 months agoMIT
vuex1,663,83328,451271 kB144-MIT
storeon18,7971,97546.8 kB15-MIT
Feature Comparison: redux vs mobx vs vuex vs storeon

Reactivity Model

  • redux:

    Redux follows a more traditional approach with a unidirectional data flow. State changes are made through actions and reducers, which means the UI must explicitly subscribe to state changes, leading to more predictable but less automatic updates compared to MobX.

  • mobx:

    MobX uses a reactive programming model where state changes automatically propagate to the UI. It employs observables to track state changes, allowing components to re-render only when relevant data changes, resulting in efficient updates and minimal performance overhead.

  • vuex:

    Vuex leverages Vue's reactivity system, allowing state changes to automatically trigger updates in components that depend on that state. It provides a centralized store that integrates tightly with Vue's component architecture, ensuring a smooth reactivity experience.

  • storeon:

    Storeon provides a simple reactive model based on events. It allows components to subscribe to specific state changes, ensuring that only the necessary parts of the application re-render, promoting performance without complex reactivity mechanisms.

Boilerplate Code

  • redux:

    Redux often involves more boilerplate code due to its strict structure, requiring actions, reducers, and middleware to manage state. This can lead to a steeper learning curve but provides a clear and maintainable architecture for larger applications.

  • mobx:

    MobX requires minimal boilerplate code, making it easier to set up and use. Its reactive nature allows developers to focus on building features rather than managing complex state logic, which can speed up development time.

  • vuex:

    Vuex has a moderate amount of boilerplate, as it requires defining a store, mutations, actions, and getters. However, this structure helps maintain clarity and organization in larger Vue applications.

  • storeon:

    Storeon is designed to be lightweight with very little boilerplate. It allows developers to define stores and events succinctly, making it easy to integrate into projects without overwhelming complexity.

Middleware Support

  • redux:

    Redux has a robust middleware ecosystem, allowing developers to handle asynchronous actions, logging, and other side effects through middleware like Redux Thunk or Redux Saga. This extensibility is a significant advantage for complex applications.

  • mobx:

    MobX does not have built-in middleware support, as it focuses on simplicity and direct state management. However, developers can implement custom solutions for side effects if needed, keeping the core library lightweight.

  • vuex:

    Vuex supports plugins that can act as middleware, allowing developers to extend its functionality for logging, state persistence, or other side effects. This feature integrates well with Vue's ecosystem, providing a cohesive development experience.

  • storeon:

    Storeon supports middleware through its event system, allowing developers to create custom middleware for logging, analytics, or other side effects. This flexibility is beneficial for small to medium applications that require some level of extensibility.

Learning Curve

  • redux:

    Redux has a steeper learning curve due to its more complex architecture and the need to understand concepts like actions, reducers, and middleware. However, once mastered, it provides a powerful and predictable state management solution.

  • mobx:

    MobX has a gentle learning curve, especially for those familiar with reactive programming concepts. Its straightforward API and minimal boilerplate make it accessible for developers of varying skill levels.

  • vuex:

    Vuex is relatively easy to learn for those already familiar with Vue.js, as it follows Vue's conventions. However, understanding its concepts like state, getters, and mutations may take some time for newcomers.

  • storeon:

    Storeon is easy to learn, particularly for developers looking for a simple and effective state management solution. Its minimalistic design allows for quick onboarding and implementation without extensive knowledge of complex patterns.

Performance

  • redux:

    Redux can face performance challenges if not optimized correctly, especially with large state trees and frequent updates. However, using techniques like memoization and selective rendering can mitigate these issues, ensuring smooth performance in larger applications.

  • mobx:

    MobX excels in performance due to its fine-grained reactivity, which minimizes unnecessary re-renders. It efficiently tracks dependencies, ensuring that only components that rely on changed state are updated, leading to optimal performance in dynamic applications.

  • vuex:

    Vuex provides good performance due to its integration with Vue's reactivity system. However, performance can be impacted if state management becomes overly complex or if components are not optimized for reactivity.

  • storeon:

    Storeon is designed for performance, as it only re-renders components that are subscribed to specific state changes. This lightweight approach ensures that applications remain responsive and efficient, even as they scale.

How to Choose: redux vs mobx vs vuex vs storeon
  • redux:

    Choose Redux if you need a predictable state container that emphasizes immutability and a unidirectional data flow. It is best for larger applications where state management complexity can grow, and you want to leverage middleware for side effects and asynchronous actions.

  • mobx:

    Choose MobX if you prefer a more reactive programming model with minimal boilerplate code. It is ideal for applications that require fine-grained reactivity and automatic dependency tracking, making it suitable for smaller to medium-sized applications.

  • vuex:

    Choose Vuex if you are working within the Vue.js ecosystem and need a state management solution that integrates seamlessly with Vue components. It is designed specifically for Vue applications and provides a structured way to manage state with a clear flow.

  • storeon:

    Choose Storeon for its lightweight and minimalistic approach to state management. It is a good option for small to medium applications where simplicity and performance are key, and you want to avoid the overhead of larger libraries.

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