Has Page Reference
lightning:hasPageReference
Enables a component to take a pageReference object as an attribute.
For Use In
Lightning Experience, Salesforce Mobile App
Implement the lightning:hasPageReference interface to indicate that a Lightning component can accept a pageReference object. This capability comes by default when implementing lightning:isUrlAddressable. This interface isn't supported for components that are embedded in a flexipage.
Implementing lightning:hasPageReference provides access to the pageReference attribute. When populated, the pageReference attribute describes the current page, including its type and attributes. Only top-level page components can receive the pageReference attribute. See pageReference types in the Lightning Aura Components Developer Guide.
By using lightning:navigation, you can jump to one of these pages or components, without needing to craft a URL by hand. Note that the pageReference attribute is deeply frozen and cannot be modified. See the lightning:isUrlAddressable documentation for examples on using and changing the pageReference.
To update a parameter on the pageReference while staying on the current page, use a change handler to listen for page state updates. Updating a parameter also updates the URL so that some state or data that the page holds can be retained, even when the page refreshes.
When the target of a navigation action maps to the same component, the routing container might simply update the pageReference attribute value instead of recreating the component. In this scenario, a change handler ensures that your component reacts correctly.
The pageReference attribute can be populated only for the following page types:
- standard__component
- standard__navItemPage (for Lightning component tab only)
- standard__recordPage
- standard__objectPage
