redux vs mobx vs vuex vs dva
State Management Libraries for JavaScript Applications
reduxmobxvuexdvaSimilar Packages:

State Management Libraries for JavaScript Applications

redux, mobx, vuex, and dva are all libraries designed to manage global state in JavaScript applications, but they serve different frameworks and follow distinct architectural patterns. redux is the industry standard for React, enforcing a strict unidirectional data flow with immutable updates. mobx offers a more flexible, observable-based approach that feels closer to object-oriented programming. vuex is the official state management solution for Vue.js, integrating tightly with Vue's reactivity system. dva is a lightweight framework built on top of redux and redux-saga, aiming to simplify boilerplate for React applications through a model-based architecture.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
redux30,201,95761,503290 kB573 years agoMIT
mobx3,296,26128,2054.8 MB5819 days agoMIT
vuex1,468,35428,312271 kB143-MIT
dva32,95816,146902 kB29-MIT

Redux vs MobX vs Vuex vs Dva: Architecture, Boilerplate, and Framework Fit

Managing state in modern web applications requires balancing flexibility, predictability, and developer experience. redux, mobx, vuex, and dva all solve the problem of shared state, but they approach it from different angles. Let's compare how they handle state updates, async logic, and framework integration.

πŸ”„ State Mutation: Immutable vs Mutable vs Reactive

redux enforces immutable state updates.

  • You cannot change state directly.
  • You must dispatch actions that reducers process to return new state objects.
// redux: Immutable update via reducer
const reducer = (state = { count: 0 }, action) => {
  if (action.type === 'INCREMENT') {
    return { ...state, count: state.count + 1 };
  }
  return state;
};

mobx allows mutable state updates via observables.

  • You change properties directly on the state object.
  • The library tracks changes and updates components automatically.
// mobx: Mutable update via observable
import { makeAutoObservable } from 'mobx';

class Store {
  count = 0;
  constructor() {
    makeAutoObservable(this);
  }
  increment() {
    this.count += 1;
  }
}

vuex uses mutations for synchronous state changes.

  • State is reactive via Vue's reactivity system.
  • Direct mutation is discouraged; you commit mutations instead.
// vuex: Mutation-based update
const store = createStore({
  state: { count: 0 },
  mutations: {
    increment(state) {
      state.count++;
    }
  }
});

dva relies on Redux under the hood but abstracts it into models.

  • State updates happen through reducers defined in models.
  • It follows Redux's immutability rules but with less wiring.
// dva: Reducer in model
export default {
  namespace: 'count',
  state: { count: 0 },
  reducers: {
    add(state, { payload }) {
      return { ...state, count: state.count + payload };
    }
  }
};

⚑ Handling Async Logic: Middleware vs Actions vs Effects

redux requires middleware for async logic.

  • Common choices are redux-thunk or redux-saga.
  • Action creators return functions or promises instead of plain objects.
// redux: Async with thunk
const fetchData = () => async (dispatch) => {
  const res = await api.get('/data');
  dispatch({ type: 'DATA_LOADED', payload: res });
};

mobx handles async logic in standard class methods.

  • No special middleware is needed.
  • You can use async/await directly inside actions.
// mobx: Async in action
class Store {
  async fetchData() {
    const res = await api.get('/data');
    this.data = res;
  }
}

vuex uses actions for async operations.

  • Actions commit mutations after async tasks complete.
  • They are defined separately from mutations in the store.
// vuex: Async action
const store = createStore({
  actions: {
    async fetchData({ commit }) {
      const res = await api.get('/data');
      commit('SET_DATA', res);
    }
  }
});

dva uses effects for async logic.

  • Effects are generator functions (sagas) built-in.
  • They yield calls to APIs and dispatch actions upon completion.
// dva: Effect in model
export default {
  effects: {
    *fetchData(_, { put, call }) {
      const res = yield call(api.get, '/data');
      yield put({ type: 'save', payload: res });
    }
  }
};

πŸ”— Framework Coupling: React vs Vue vs Agnostic

redux is framework-agnostic but heavily optimized for React.

  • Works with vanilla JS, Angular, or Vue, but React bindings (react-redux) are standard.
  • Requires manual subscription setup for non-React environments.
// redux: Manual subscription (non-React)
store.subscribe(() => {
  console.log('State changed:', store.getState());
});

mobx is fully framework-agnostic.

  • Has first-class bindings for React (mobx-react), Vue (mobx-vue), and others.
  • Core logic does not depend on any UI library.
// mobx: React binding
import { observer } from 'mobx-react';
const Component = observer(({ store }) => <div>{store.count}</div>);

vuex is tightly coupled to Vue.js.

  • Cannot be used effectively without Vue.
  • Integrates directly into the Vue instance via provide/inject.
// vuex: Vue integration
const app = createApp(App);
app.use(store);
app.mount('#app');

dva is designed for React applications.

  • Built on top of react-redux and react-router.
  • Not suitable for Vue or vanilla JS projects.
// dva: React app setup
import dva from 'dva';
const app = dva();
app.router(({ history }) => <Router history={history} />);
app.start('#root');

πŸ› οΈ Boilerplate & Setup Complexity

The amount of code required to set up a simple counter varies significantly.

  • redux requires defining action types, action creators, and reducers. High boilerplate without Toolkit.
  • mobx requires minimal setup β€” just define a class and observe it.
  • vuex requires defining state, mutations, and actions in a store file.
  • dva requires defining models with namespace, state, reducers, and effects.

πŸ’‘ Tip: If you choose redux today, use Redux Toolkit. It reduces boilerplate by about 70% compared to vanilla redux.

⚠️ Maintenance & Future Outlook

Not all libraries are moving at the same speed.

  • redux is actively maintained. It is the backbone of many enterprise apps. The ecosystem is shifting towards Redux Toolkit and RTK Query.
  • mobx is actively maintained. It remains a popular alternative for those who find Redux too verbose.
  • vuex is in maintenance mode for Vue 3. The Vue team now recommends Pinia for new projects, though vuex is still stable for Vue 2.
  • dva has seen reduced activity. It is considered legacy by many in the React community. New projects should evaluate Redux Toolkit or server-state tools like React Query instead.
// Example: Checking store creation in modern vs legacy
// Redux (Legacy)
const store = createStore(reducer);

// Redux (Modern Toolkit)
const store = configureStore({ reducer });

πŸ“Š Summary: Key Differences

Featurereduxmobxvuexdva
State UpdateImmutableMutableMutable (via mutations)Immutable
Async LogicMiddleware (Thunk/Saga)Class MethodsActionsEffects (Sagas)
FrameworkAgnostic (React focused)AgnosticVue OnlyReact Only
BoilerplateHigh (Low with Toolkit)LowMediumMedium
StatusActiveActiveMaintenance (Vue 3)Legacy/Maintenance

🀝 Similarities: Shared Ground

Despite their differences, these libraries share common goals and patterns.

1. πŸ“¦ Centralized Store

  • All four provide a single source of truth for application state.
  • Components subscribe to the store to receive updates.
// All: Accessing state
// Redux: state.count
// MobX: store.count
// Vuex: store.state.count
// Dva: state.count

2. πŸ”Œ DevTools Support

  • All support browser extensions for time-travel debugging and state inspection.
  • Essential for tracking down bugs in complex flows.
// All: DevTools integration
// Redux: window.__REDUX_DEVTOOLS_EXTENSION__
// MobX: mobx-devtools
// Vuex: Vue Devtools
// Dva: Redux Devtools (inherits from Redux)

3. 🧩 Modular Architecture

  • All allow splitting state into modules or namespaces.
  • Helps organize code in large applications.
// Redux: combineReducers
// MobX: Multiple stores
// Vuex: Modules
// Dva: Models (namespaces)

πŸ’‘ The Big Picture

redux is the safe, enterprise-grade choice for React. It enforces discipline that pays off in large teams. Use it with Redux Toolkit to avoid unnecessary boilerplate.

mobx is the productivity-focused choice. It feels more natural for developers coming from object-oriented backgrounds. Great for mid-sized apps where speed matters.

vuex is the default for Vue 2 and legacy Vue 3. If you are starting fresh on Vue 3, look at Pinia, but vuex is still reliable for existing codebases.

dva is a legacy abstraction over Redux. It was popular in the Ant Design ecosystem but has faded. Avoid it for new projects unless you are maintaining an existing system.

Final Thought: State management is not one-size-fits-all. Match the tool to your framework and team size. For React, redux (with Toolkit) or mobx are the leaders. For Vue, vuex or Pinia rule. Avoid dva for new work.

How to Choose: redux vs mobx vs vuex vs dva

  • redux:

    Choose redux if you are building a React application that requires predictable state transitions and strict debugging capabilities. It is ideal for large-scale enterprise apps where traceability and time-travel debugging are critical. Be aware that modern Redux development typically involves Redux Toolkit to reduce boilerplate, though the core redux package provides the foundational store logic.

  • mobx:

    Choose mobx if you prefer a less verbose, more intuitive approach to state management that allows mutable updates via observables. It works well for React applications where you want to avoid the strict boilerplate of Redux while maintaining reactivity. It is also framework-agnostic, making it suitable for projects that might mix different UI libraries.

  • vuex:

    Choose vuex if you are working on a Vue.js 2 or Vue.js 3 project and need official, integrated state management. It leverages Vue's reactivity system, making it seamless to use within Vue components. Note that for new Vue 3 projects, the community often recommends Pinia, but vuex remains the stable choice for existing Vue 2 ecosystems.

  • dva:

    Choose dva if you are maintaining a legacy React application that already relies on its model-based architecture combining Redux and Sagas. It simplifies async logic and reducer wiring but is less actively developed than core Redux. For new React projects, consider modern Redux patterns or other frameworks instead of starting with dva.

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:

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