redux vs effector vs mobx vs rxjs
State Management and Reactive Streams in Frontend Architecture
reduxeffectormobxrxjsSimilar Packages:

State Management and Reactive Streams in Frontend Architecture

redux, mobx, effector, and rxjs are all tools for managing state and data flow in JavaScript applications, but they solve the problem in very different ways. redux relies on a single immutable store and pure functions to manage state changes, making it predictable but verbose. mobx uses mutable state with automatic dependency tracking, allowing for a more object-oriented style. effector focuses on isolated units of state and events with a functional approach, designed for performance and type safety. rxjs is a library for reactive programming using observables, handling streams of data over time rather than just static state.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
redux33,429,26561,477290 kB492 years agoMIT
effector04,8361.59 MB1589 months agoMIT
mobx028,1914.43 MB65a day agoMIT
rxjs031,6824.5 MB297a year agoApache-2.0

State Management and Reactive Streams in Frontend Architecture

redux, mobx, effector, and rxjs are all tools for managing state and data flow in JavaScript applications, but they work differently under the hood. Let's compare how they tackle common problems like updating data, connecting to UI, and handling async logic.

🧠 Core Mental Model: Store vs Observable vs Unit

redux uses a single immutable store for the whole app.

  • State is read-only and changed by dispatching actions.
  • You write pure functions called reducers to specify how state changes.
// redux: Define slice and store
import { configureStore, createSlice } from '@reduxjs/toolkit';

const counterSlice = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: { increment: (state) => { state.value += 1; } }
});

const store = configureStore({ reducer: { counter: counterSlice.reducer } });

mobx uses mutable state with automatic tracking.

  • You mark objects as observable, and MobX watches for changes.
  • Components re-render automatically when observed data changes.
// mobx: Create observable store
import { makeAutoObservable } from 'mobx';

class CounterStore {
  value = 0;
  constructor() { makeAutoObservable(this); }
  increment() { this.value += 1; }
}

const store = new CounterStore();

effector uses isolated units called stores and events.

  • You create separate stores for different pieces of state.
  • Events trigger updates, and stores hold the data.
// effector: Create store and event
import { createStore, createEvent } from 'effector';

const increment = createEvent();
const $counter = createStore(0).on(increment, (count) => count + 1);

rxjs uses streams of data called observables.

  • Data flows over time, and you subscribe to receive values.
  • It is not a state manager by default, but BehaviorSubject can hold state.
// rxjs: Create state stream
import { BehaviorSubject } from 'rxjs';

const counter$ = new BehaviorSubject(0);

// Update value
counter$.next(counter$.value + 1);

✍️ Updating State: Dispatch vs Action vs Event vs Next

redux requires dispatching an action object.

  • You cannot change state directly; you send a request to change it.
  • This makes changes explicit and easy to log.
// redux: Dispatch action
store.dispatch({ type: 'counter/increment' });
// Or with toolkit slice actions
store.dispatch(counterSlice.actions.increment());

mobx allows direct mutation inside actions.

  • You call methods that change properties directly.
  • MobX detects the change and notifies listeners.
// mobx: Call action method
store.increment();
// Or direct mutation if auto-observable
store.value += 1;

effector triggers an event to update the store.

  • Events are functions you call to pass payload data.
  • Stores listen to events and update based on logic.
// effector: Trigger event
increment();
// Or with payload
const setCount = createEvent();
setCount(10);

rxjs pushes a new value into the stream.

  • You call next() on the subject to emit new data.
  • Subscribers receive the new value asynchronously.
// rxjs: Emit new value
counter$.next(5);

βš›οΈ React Integration: Selector vs Observer vs Unit vs Hook

redux uses hooks to select data from the store.

  • useSelector subscribes the component to specific state slices.
  • useDispatch gives you the function to send actions.
// redux: React hooks
import { useSelector, useDispatch } from 'react-redux';

function Counter() {
  const count = useSelector((state) => state.counter.value);
  const dispatch = useDispatch();
  return <button onClick={() => dispatch(increment())}>{count}</button>;
}

mobx wraps components to track usage.

  • observer makes a component react to changes in observable data.
  • It automatically re-renders when observed data changes.
// mobx: Observer component
import { observer } from 'mobx-react-lite';

const Counter = observer(({ store }) => {
  return <button onClick={() => store.increment()}>{store.value}</button>;
});

effector binds stores directly to components.

  • useUnit hooks into stores and events efficiently.
  • It prevents unnecessary re-renders by tracking specific units.
// effector: React unit hook
import { useUnit } from 'effector-react';

function Counter() {
  const count = useUnit($counter);
  const inc = useUnit(increment);
  return <button onClick={inc}>{count}</button>;
}

rxjs requires a hook to subscribe to streams.

  • Libraries like rxjs-react or custom hooks are needed.
  • You must manage subscription cleanup manually or via hooks.
// rxjs: Custom hook pattern
import { useEffect, useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);
  useEffect(() => {
    const sub = counter$.subscribe(setCount);
    return () => sub.unsubscribe();
  }, []);
  return <button onClick={() => counter$.next(count + 1)}>{count}</button>;
}

⏳ Handling Async Logic: Thunks vs Flows vs Effects vs Operators

redux uses middleware like Thunks or Sagas.

  • Thunks allow functions that dispatch actions after async work.
  • Sagas use generators for complex async flows.
// redux: Async thunk
import { createAsyncThunk } from '@reduxjs/toolkit';

const fetchData = createAsyncThunk('data/fetch', async () => {
  const res = await fetch('/api');
  return res.json();
});

mobx uses flow for async actions.

  • It wraps async functions to track state changes during awaits.
  • Looks like async/await but integrates with MobX tracking.
// mobx: Async flow
import { flow } from 'mobx';

class Store {
  fetchData = flow(function* () {
    const res = yield fetch('/api');
    this.data = yield res.json();
  });
}

effector uses effects for side effects.

  • Effects are units that handle async operations and return promises.
  • They integrate with stores via sample or attach.
// effector: Async effect
import { createEffect } from 'effector';

const fetchData = createEffect(async () => {
  const res = await fetch('/api');
  return res.json();
});

rxjs uses operators to manage async streams.

  • Operators like switchMap or mergeMap handle requests.
  • You can cancel requests by unsubscribing or switching streams.
// rxjs: Async operator
import { switchMap } from 'rxjs/operators';

stream$.pipe(
  switchMap(() => fetch('/api').then(res => res.json()))
).subscribe(data => console.log(data));

πŸ› οΈ Debugging and Tooling

redux has the most mature DevTools.

  • Time-travel debugging lets you rewind state changes.
  • Action logs show exactly what changed and why.
// redux: DevTools setup
// Automatically included in configureStore
const store = configureStore({ reducer: { ... } });

mobx has DevTools for tracking reactions.

  • You can see which observables triggered which components.
  • Less focus on history, more on dependency graphs.
// mobx: DevTools
import { configure } from 'mobx';
configure({ enforceActions: 'always' });

effector has its own DevTools extension.

  • Shows store updates and event triggers visually.
  • Supports tracing event chains across the app.
// effector: DevTools
import { inspect } from '@effector/inspect';
inspect();

rxjs relies on logging or marble diagrams.

  • No standard UI DevTools for React integration.
  • Developers often use tap operator to log stream values.
// rxjs: Logging stream
import { tap } from 'rxjs/operators';
stream$.pipe(tap(val => console.log(val))).subscribe();

🀝 Similarities: Shared Ground Between Libraries

While the differences are clear, these libraries also share many core ideas and tools. Here are key overlaps:

1. πŸ”„ Reactive Updates

  • All four libraries update the UI when data changes.
  • They avoid manual DOM manipulation by syncing state to view.
// Example: All trigger UI updates
// redux: dispatch -> reducer -> selector -> render
// mobx: action -> observable -> observer -> render
// effector: event -> store -> unit -> render
// rxjs: next -> subscribe -> setState -> render

2. πŸ“¦ Ecosystem Support

  • All have dedicated React bindings or community hooks.
  • Supported by TypeScript with strong type definitions.
// Example: TypeScript support
// redux: TypedUseSelectorHook
// mobx: IReactionDisposer
// effector: Store<T>
// rxjs: Observable<T>

3. ⚑ Performance Optimization

  • All aim to minimize unnecessary re-renders.
  • They provide mechanisms to select specific data slices.
// Example: Selecting data
// redux: useSelector(state => state.user)
// mobx: observer accesses this.props.user
// effector: useUnit($user)
// rxjs: distinctUntilChanged()

πŸ“Š Summary: Key Differences

Featurereduxmobxeffectorrxjs
State ModelπŸ—„οΈ Immutable Single Store🧱 Mutable Objects🧩 Isolated Units🌊 Streams
Update MethodπŸ“€ Dispatch Actions✏️ Direct Mutation⚑ Trigger Events➑️ Emit Values
React BindingπŸͺ useSelector🧐 observerπŸ”Œ useUnitπŸ“ž subscribe / Hooks
Async Handling🧡 Thunks / Sagas🌊 flow🎯 effectsπŸ› οΈ Operators
Learning CurveπŸ“ˆ Steep (Boilerplate)πŸ“‰ Low (Magic)πŸ“Š Medium (Functional)πŸ“ˆ High (Reactive)
DevToolsπŸ† Excellent (Time Travel)βœ… Good (Reaction Graph)βœ… Good (Unit Trace)⚠️ Limited (Logging)

πŸ’‘ The Big Picture

redux is like a strict ledger πŸ“’ β€” great for teams that need predictability, audit trails, and a standard pattern everyone knows. Ideal for large enterprise apps where state changes must be explicit.

mobx is like a spreadsheet πŸ“Š β€” perfect for teams who want to write less code and prefer mutable state. It shines in complex domain models where automatic tracking saves time.

effector is like a circuit board πŸ”Œ β€” best for developers who want high performance and type safety without Redux verbosity. It works well for apps that need fine-grained control over re-renders.

rxjs is like a water pipe system 🚰 β€” designed for handling complex streams of events over time. It is the go-to for heavy async logic, websockets, or event-heavy interfaces.

Final Thought: There is no single best tool. redux offers stability, mobx offers speed of development, effector offers balance and performance, and rxjs offers power for streams. Choose based on your team's comfort with functional vs object-oriented styles and the complexity of your data flow.

How to Choose: redux vs effector vs mobx vs rxjs

  • redux:

    Choose redux (specifically Redux Toolkit) if you need a predictable state container with a large ecosystem and strict unidirectional data flow. It is best for teams that value explicit state changes and time-travel debugging, especially in large organizations where consistency is key. It is the standard choice when integrating with many third-party libraries that expect a Redux store.

  • effector:

    Choose effector if you want a balance between structure and flexibility without the boilerplate of Redux. It is ideal for large applications where type safety and performance are critical, as it avoids re-renders by default and has a unique unit-based architecture. It works well for teams that prefer functional programming patterns but find Redux too rigid.

  • mobx:

    Choose mobx if you prefer mutable state and want to write less boilerplate code. It is suitable for applications where state logic resembles object-oriented design, allowing you to modify state directly without dispatchers. It shines in rapid prototyping and complex domain models where automatic dependency tracking reduces manual wiring.

  • rxjs:

    Choose rxjs if your application deals heavily with asynchronous events, streams, or complex event composition rather than simple UI state. It is perfect for handling websockets, user input streams, or canceling ongoing requests. It is less about UI state management and more about managing data flows over time.

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