lightning/stateManager* State Managers

Using state managers, pro-code developers can decouple data-related concerns from component logic. Moving data access out of individual components and into a dedicated state layer helps the Salesforce platform manage data more efficiently. This separation is especially useful for complex applications with many synchronized components, as data is managed separately from user interface concerns.

State management is not available in Experience Cloud at this time.

Lightning Data Service (LDS) wire adapters perform read operations and imperative functions for mutation operations (creates, updates, and deletes) on platform data. They're coupled to a specific component and are the preferred choice for standalone, context-independent units that access data at the component level.

You can't use wire adapters within state managers because wire adapters require a component context and state managers aren't components. While you can technically replace a wire adapter with a built-in state manager, this doesn't reap the architectural benefits of setting up state management.

Instead, use state managers when your goal is to build a coordinated, consolidated data-access system at the page or app level. They should bridge multiple elements and manage complex data retrieval or metadata parsing in one location. See Best Practices for State Manager Design for more detailed guidelines.

To support state manager composition, Salesforce provides a set of built-in state managers that wrap LDS access to the most common UI API data and metadata. These state managers follow a consistent design pattern, and participate fully in the LDS normalization, caching, and subscription mechanisms.

State managers in these modules are built on top of Lightning Data Service (LDS) and User Interface API. Use these state managers to work with Salesforce data and metadata.

See Also