Refresh Component Data with RefreshView API
Whether user-driven or app-invoked, the ability to synchronize data without reloading an entire page is a key user experience requirement. The RefreshView API and lightning/refresh
module provide a standard way to refresh component data in LWC and Aura.
RefreshView API’s detailed control of refresh scope lets you create refined user experiences while maintaining backward compatibility.
RefreshView API gives you the option to update a hierarchy of components, known as a view, without reloading an entire page. This refresh ensures complete synchronization with data externally sourced by components that subscribe to the refresh event in that view. RefreshView API supports refreshes that are triggered by end users or web components. RefreshView API provides a standard mechanism for data refresh experiences in LWC components, allowing flexible control of refresh scopes.
RefreshView API can refresh data for Salesforce platform containers and custom LWC and Aura components.
Lightning Data Service supports RefreshView API. However, a custom component must initiate the actual data refresh. For example, call refreshApex()
to refresh Apex data provisioned via the wire service. Or call refreshGraphQL()
to update the data provisioned by the GraphQL wire adapter. See Data Guidelines.
RefreshView API can work in orgs that have enabled Lightning Web Security or Lightning Locker. The protocol for registering containers and handlers is different for each security architecture.
The base Lightning Aura components currently don’t support RefreshView API.
If a component uses the wire service, record data is updated via the @wire(getRecord)
. Lightning Data Service keeps the data provisioned by the wire service updated each time the record is changed via any Lightning Data Service calls. If the record is updated via a server action such as an Apex call, call notifyRecordUpdateAvailable
to update the @wire
. These calls are done outside the context of RefreshView API.
See Also