Mobx Query

Installation

Install mobx-query and its required peer dependencies.

Install mobx-query

npm install @mobx-query/core

Peer Dependencies

mobx-query requires the following peer dependencies:

PackagePurpose
@tanstack/react-queryServer-state caching, refetching, and mutations
mobxObservable state and reactive computed properties
mobx-react-liteReact bindings — the observer() HOC for components
npm install @tanstack/react-query mobx mobx-react-lite

If you already have these packages in your project, you can skip the peer dependency installation step. mobx-query is compatible with MobX 6+, mobx-react-lite 3+, and TanStack Query v5.

TypeScript Configuration

mobx-query is written in TypeScript and ships with full type definitions — no additional @types/* packages are needed.

Decorators

mobx-query entities use the TC39 decorator proposal (stage 3) with the accessor keyword. Make sure your tsconfig.json is configured to support them:

tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": false,
    "useDefineForClassFields": true
  }
}

Do not enable experimentalDecorators. mobx-query uses the modern TC39 decorators, which are incompatible with the legacy TypeScript decorator implementation.

Verify Installation

Create a quick smoke test to verify everything is wired up:

verify.ts
import { QueryClient } from "@tanstack/react-query";
import { MQClient } from "@mobx-query/core";

const queryClient = new QueryClient();

const client = new MQClient({
  context: { queryClient },
  entities: [],
  rootStore: () => ({}),
});

console.log("✅ mobx-query is installed correctly!");

Run this file — if you see the success message, you're good to go.

On this page