Installation
Install mobx-query and its required peer dependencies.
Install mobx-query
npm install @mobx-query/corePeer Dependencies
mobx-query requires the following peer dependencies:
| Package | Purpose |
|---|---|
@tanstack/react-query | Server-state caching, refetching, and mutations |
mobx | Observable state and reactive computed properties |
mobx-react-lite | React bindings — the observer() HOC for components |
npm install @tanstack/react-query mobx mobx-react-liteIf 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:
{
"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:
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.