Skip to main content

MobX integration (advanced)

Only for MobX users

This section is intended for developers who are already using MobX in their application and don't want to use the built-in React, Vue or Reactive bindings.

SyncedStore works seamlessly together with the MobX FRP library. To enable this, call enableMobxBindings once, for example when setting up your store.

import * as mobx from "mobx";
import { enableMobxBindings } from "@syncedstore/core";



You can now use mobx functionality such as reactions, autorun, etc. You can also use mobx-react to combine SyncedStore, mobx, and React.

Compared to the default React example, we now wrap the component using observer, and we don't need the useSyncedStore hook anymore.

import React from "react";
import { store } from "./store";
import { observer } from "mobx-react-lite";
import * as mobx from "mobx";
import { enableMobxBindings } from "@syncedstore/core";

// enable mobx bindings

// use the observer pattern from mobx-react-lite.
export const App = observer(() => {
  return (
      <p>Todo items:</p>
        {, i) => {
          return (
            <li key={i} style={{ textDecoration: todo.completed ? "line-through" : "" }}>
                <input type="checkbox" checked={todo.completed} onClick={() => (todo.completed = !todo.completed)} />
        placeholder="Enter a todo item and hit enter"
        onKeyPress={(event) => {
          if (event.key === "Enter") {
            const target = as HTMLInputElement;
            // Add a todo item using the text added in the textfield
            store.todos.push({ completed: false, title: target.value });
            target.value = "";
        style={{ width: "200px", maxWidth: "100%" }}

export default App;