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.
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.
redux enforces immutable state updates.
// 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.
// 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.
// 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.
// dva: Reducer in model
export default {
namespace: 'count',
state: { count: 0 },
reducers: {
add(state, { payload }) {
return { ...state, count: state.count + payload };
}
}
};
redux requires middleware for async logic.
redux-thunk or redux-saga.// 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.
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.
// 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.
// dva: Effect in model
export default {
effects: {
*fetchData(_, { put, call }) {
const res = yield call(api.get, '/data');
yield put({ type: 'save', payload: res });
}
}
};
redux is framework-agnostic but heavily optimized for React.
react-redux) are standard.// redux: Manual subscription (non-React)
store.subscribe(() => {
console.log('State changed:', store.getState());
});
mobx is fully framework-agnostic.
mobx-react), Vue (mobx-vue), and others.// mobx: React binding
import { observer } from 'mobx-react';
const Component = observer(({ store }) => <div>{store.count}</div>);
vuex is tightly coupled to Vue.js.
provide/inject.// vuex: Vue integration
const app = createApp(App);
app.use(store);
app.mount('#app');
dva is designed for React applications.
react-redux and react-router.// dva: React app setup
import dva from 'dva';
const app = dva();
app.router(({ history }) => <Router history={history} />);
app.start('#root');
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
reduxtoday, useRedux Toolkit. It reduces boilerplate by about 70% compared to vanillaredux.
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 });
| Feature | redux | mobx | vuex | dva |
|---|---|---|---|---|
| State Update | Immutable | Mutable | Mutable (via mutations) | Immutable |
| Async Logic | Middleware (Thunk/Saga) | Class Methods | Actions | Effects (Sagas) |
| Framework | Agnostic (React focused) | Agnostic | Vue Only | React Only |
| Boilerplate | High (Low with Toolkit) | Low | Medium | Medium |
| Status | Active | Active | Maintenance (Vue 3) | Legacy/Maintenance |
Despite their differences, these libraries share common goals and patterns.
// All: Accessing state
// Redux: state.count
// MobX: store.count
// Vuex: store.state.count
// Dva: state.count
// All: DevTools integration
// Redux: window.__REDUX_DEVTOOLS_EXTENSION__
// MobX: mobx-devtools
// Vuex: Vue Devtools
// Dva: Redux Devtools (inherits from Redux)
// Redux: combineReducers
// MobX: Multiple stores
// Vuex: Modules
// Dva: Models (namespaces)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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!
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:
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:
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.
You can find the official logo on GitHub.
This project adheres to Semantic Versioning. Every release, along with the migration instructions, is documented on the GitHub Releases page.