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.
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.
redux uses a single immutable store for the whole app.
// 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.
// 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.
// 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.
BehaviorSubject can hold state.// rxjs: Create state stream
import { BehaviorSubject } from 'rxjs';
const counter$ = new BehaviorSubject(0);
// Update value
counter$.next(counter$.value + 1);
redux requires dispatching an action object.
// redux: Dispatch action
store.dispatch({ type: 'counter/increment' });
// Or with toolkit slice actions
store.dispatch(counterSlice.actions.increment());
mobx allows direct mutation inside actions.
// mobx: Call action method
store.increment();
// Or direct mutation if auto-observable
store.value += 1;
effector triggers an event to update the store.
// effector: Trigger event
increment();
// Or with payload
const setCount = createEvent();
setCount(10);
rxjs pushes a new value into the stream.
next() on the subject to emit new data.// rxjs: Emit new value
counter$.next(5);
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.// 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.// 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.
rxjs-react or custom hooks are needed.// 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>;
}
redux uses middleware like Thunks or Sagas.
// 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.
// 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.
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.
switchMap or mergeMap handle requests.// rxjs: Async operator
import { switchMap } from 'rxjs/operators';
stream$.pipe(
switchMap(() => fetch('/api').then(res => res.json()))
).subscribe(data => console.log(data));
redux has the most mature DevTools.
// redux: DevTools setup
// Automatically included in configureStore
const store = configureStore({ reducer: { ... } });
mobx has DevTools for tracking reactions.
// mobx: DevTools
import { configure } from 'mobx';
configure({ enforceActions: 'always' });
effector has its own DevTools extension.
// effector: DevTools
import { inspect } from '@effector/inspect';
inspect();
rxjs relies on logging or marble diagrams.
tap operator to log stream values.// rxjs: Logging stream
import { tap } from 'rxjs/operators';
stream$.pipe(tap(val => console.log(val))).subscribe();
While the differences are clear, these libraries also share many core ideas and tools. Here are key overlaps:
// 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
// Example: TypeScript support
// redux: TypedUseSelectorHook
// mobx: IReactionDisposer
// effector: Store<T>
// rxjs: Observable<T>
// Example: Selecting data
// redux: useSelector(state => state.user)
// mobx: observer accesses this.props.user
// effector: useUnit($user)
// rxjs: distinctUntilChanged()
| Feature | redux | mobx | effector | rxjs |
|---|---|---|---|---|
| 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) |
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.
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.
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.
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.
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.
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.