redux vs mobx vs flux
State Management Architectures for React Applications
reduxmobxfluxSimilar Packages:

State Management Architectures for React Applications

flux, mobx, and redux are libraries for managing application state, but they follow different architectural patterns. flux is the original reference implementation of the unidirectional data flow pattern created by Facebook. redux is a popular, predictable state container inspired by Flux but with a single store and pure reducers. mobx takes a different approach by using observables to automatically track state changes and update the UI, feeling more like traditional object-oriented programming.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
redux33,155,08361,447290 kB422 years agoMIT
mobx3,427,06028,1844.35 MB807 months agoMIT
flux1,394,66017,471260 kB63 years agoBSD-3-Clause

Flux vs Redux vs MobX: State Management Architectures Compared

flux, mobx, and redux all solve the problem of managing complex state in JavaScript applications, but they work differently under the hood. Let's compare how they tackle common problems like data flow, state updates, and UI integration.

πŸ—‚οΈ Core Data Flow: Unidirectional vs Observables

flux enforces a strict unidirectional flow using a central dispatcher.

  • Actions trigger the dispatcher.
  • The dispatcher sends payloads to registered stores.
  • Stores update and emit change events.
// flux: Dispatcher and Store pattern
var Dispatcher = require('flux').Dispatcher;
var dispatcher = new Dispatcher();

var Store = require('flux').Store;
var myStore = new Store(dispatcher);
myStore.on('change', () => { /* update UI */ });

redux simplifies Flux into a single store with pure reducers.

  • Actions are plain objects sent to the store.
  • Reducers specify how state changes in response to actions.
  • No central dispatcher is needed.
// redux: Store and Reducer pattern
import { createStore } from 'redux';

function reducer(state = {}, action) {
  if (action.type === 'ADD') return { count: state.count + 1 };
  return state;
}

const store = createStore(reducer);
store.dispatch({ type: 'ADD' });

mobx uses observables to track state automatically.

  • You modify state directly inside actions.
  • Observers (like React components) re-render when observables change.
  • No explicit dispatching or reducers required.
// mobx: Observable and Action pattern
import { makeAutoObservable } from 'mobx';

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

const counter = new Counter();
counter.increment();

✍️ Updating State: Explicit vs Implicit

flux requires you to define action creators and handle payloads manually.

  • You must define what the action looks like.
  • Stores switch on action types to update internal state.
  • More boilerplate to wire everything together.
// flux: Action Creator
var ActionCreator = {
  add: function(text) {
    dispatcher.dispatch({
      type: 'ADD_ITEM',
      text: text
    });
  }
};

redux requires pure functions that return new state objects.

  • You cannot mutate the existing state.
  • Every update creates a new state tree.
  • Makes time-travel debugging possible.
// redux: Pure Reducer
function reducer(state = { items: [] }, action) {
  switch (action.type) {
    case 'ADD_ITEM':
      return { items: [...state.items, action.text] };
    default:
      return state;
  }
}

mobx allows direct mutation inside actions.

  • You change properties like normal objects.
  • MobX detects the change and notifies observers.
  • Feels more natural for developers coming from OOP backgrounds.
// mobx: Direct Mutation
import { action } from 'mobx';

class Store {
  items = [];
  
  addItem = action((text) => {
    this.items.push(text); // Direct mutation is allowed
  });
}

βš›οΈ React Integration: Mixins vs Connect vs Observer

flux originally relied on mixins or higher-order components.

  • Components subscribe to store change events.
  • You must manually call setState when stores change.
  • More prone to memory leaks if unsubscribing is forgotten.
// flux: Manual Subscription
class Component extends React.Component {
  componentDidMount() {
    this.store.addChangeListener(this.onChange);
  }
  onChange() {
    this.setState({ data: this.store.getData() });
  }
}

redux uses connect or hooks like useSelector.

  • Components subscribe to specific parts of the state.
  • Updates are optimized to prevent unnecessary renders.
  • react-redux handles the subscription lifecycle.
// redux: React-Redux Hooks
import { useSelector, useDispatch } from 'react-redux';

function Component() {
  const count = useSelector(state => state.count);
  const dispatch = useDispatch();
  return <button onClick={() => dispatch({ type: 'ADD' })}>{count}</button>;
}

mobx uses the observer wrapper.

  • Components automatically track which observables they use.
  • Only re-renders when relevant data changes.
  • Very little boilerplate to connect state to UI.
// mobx: Observer Component
import { observer } from 'mobx-react';

const Component = observer(({ store }) => {
  return <button onClick={() => store.addItem('New')}>{store.items.length}</button>;
});

πŸ› οΈ Debugging & Tooling Support

flux has basic tooling support.

  • Since it is the reference implementation, dev tools are limited.
  • You rely on console logging to trace dispatcher payloads.
  • Harder to visualize state changes over time.
// flux: Manual Logging
dispatcher.register(function(payload) {
  console.log('Dispatched:', payload);
});

redux has industry-leading dev tools.

  • Redux DevTools allows time-travel debugging.
  • You can see every action and state change in a timeline.
  • Great for tracking down bugs in complex flows.
// redux: DevTools Enhancement
import { createStore } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(reducer, composeWithDevTools());

mobx has strong reactive inspection tools.

  • MobX DevTools shows observable trees and reactions.
  • You can see which components react to which data.
  • Helpful for understanding automatic dependencies.
// mobx: DevTools Integration
import { configure } from 'mobx';
configure({ enforceActions: 'observed' }); // Helps catch missing actions

πŸ“… Current Status & Maintenance

flux is considered legacy technology.

  • Facebook no longer actively develops it for modern React.
  • The architecture lives on in Redux and Context API.
  • Do not start new projects with the flux package.
// flux: Deprecated Pattern
// Avoid using the original flux package for new apps
// Use modern alternatives instead

redux is actively maintained and evolving.

  • Redux Toolkit is now the standard way to write Redux.
  • Still the go-to choice for large-scale enterprise apps.
  • Huge ecosystem of middleware and addons.
// redux: Modern Toolkit Usage
import { configureStore } from '@reduxjs/toolkit';
const store = configureStore({ reducer: rootReducer });

mobx is actively maintained and stable.

  • Popular in specific communities that prefer OOP styles.
  • Version 6+ supports modern React patterns well.
  • Good choice for rapid prototyping or complex domain models.
// mobx: Modern Version 6+
import { makeAutoObservable } from 'mobx';
// Fully compatible with React 18 and concurrent features

πŸ“Š Summary: Key Differences

Featurefluxreduxmobx
Data FlowπŸ—‚οΈ Unidirectional (Dispatcher)πŸ—‚οΈ Unidirectional (Single Store)πŸ”„ Observable (Reactive)
State Mutation❌ Immutable (Manual)❌ Immutable (Enforced)βœ… Mutable (Inside Actions)
BoilerplateπŸ”₯ HighπŸ”₯ High (Low with Toolkit)✨ Low
Dev Tools⚠️ BasicπŸ† Excellentβœ… Very Good
StatusπŸ›‘ Legacyβœ… Standardβœ… Active

πŸ’‘ The Big Picture

flux is the historical foundation πŸ›οΈ. It introduced the idea of one-way data flow, which fixed many bugs in early web apps. However, it is too verbose for modern development. Use it only for learning history or maintaining very old codebases.

redux is the enterprise standard 🏒. It trades boilerplate for predictability. If you need to debug complex state issues or work in a large team where consistency matters, Redux is the safe bet. With Redux Toolkit, the pain points are mostly gone.

mobx is the developer experience choice πŸš€. It feels like magic because it handles subscriptions for you. If you want to build features fast and prefer object-oriented code, MobX lets you focus on logic rather than wiring. Just be careful with hidden dependencies.

Final Thought: All three libraries aim to make state manageable. flux started the conversation, redux industrialized it, and mobx offered a reactive alternative. For new projects today, choose between redux (for structure) or mobx (for speed), and leave flux in the past.

How to Choose: redux vs mobx vs flux

  • redux:

    Choose redux if you need a predictable state container with a large ecosystem, strong dev tools, and a clear separation of concerns. It is ideal for large teams where explicit data flow is critical for debugging and testing.

  • mobx:

    Choose mobx if you prefer writing less boilerplate code and want state updates to happen automatically without manual wiring. It works well for teams comfortable with object-oriented patterns and mutable state who value developer speed over strict traceability.

  • flux:

    Choose flux only if you are maintaining a legacy application built on the original Facebook architecture or need to study the reference implementation of unidirectional data flow. It is not recommended for new projects due to the rise of more modern alternatives.

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