MobX State Tree is a structured, tree-based state management library for JavaScript applications that combines typed model definitions with reactive snapshots and patch-based change tracking. It provides a reactive state container with runtime and compile-time type safety, where application state is defined as a tree of typed models with collocated actions, computed views, and lifecycle hooks for predictable state mutations.
The library is built around an action-centric mutation model that encapsulates all state changes within named functions that directly modify the tree, supported by generator-based asynchronous flows that yield promises for clean async state mutations. It includes a reference and relationship system that links related models via lightweight identifier references for normalized data management, and provides immutable snapshots and JSON Patch streams that enable time-travel debugging, undo/redo patterns, and state persistence. Middleware hooks allow intercepting actions before execution for logging, modification, or cancellation.
The library supports defining structured models with typed properties, computed values, enumerations, unions, refinements, custom types, and identifier-based references for cross-tree lookups. It offers snapshot creation and application, patch recording and replay, model cloning, node destruction and detachment, and environment dependency injection. TypeScript types can be derived automatically from model definitions for compile-time safety, and the library integrates with UI frameworks by observing state changes and re-rendering components reactively.
Documentation covers model definition, action management, async flows, middleware, references, snapshots, patches, and TypeScript integration.