Newer Version Available
Lightning Navigation
Use the lightning/navigation API to navigate
to different pages within your site, generate URLs to different routes, and get the current
pageReference object.
See PageReference Types in the Lightning Web Components Developer Guide.
Aura templates support comm__namedPage schemas that use the name attribute (added in Spring ’20) and the pageName attribute (deprecated in Spring ’20). In LWR templates, only the name attribute is supported. The name of a page is its API name, which is configurable during page creation and visible on the page properties.
URLs for record detail pages behave a little differently in LWR sites than in Aura sites.
- For pages of type standard__recordPage, the URLs that are generated using the lightning/navigation API include detail as the recordName in the URL path. The proper record name is used when the user actually visits the page through a canonical URL redirect.
- If the current user visits a record detail page but doesn’t have access to the current record, there’s no canonical URL redirect and the record name can’t be resolved.
- There’s no support for pageReference type standard__namedPage. Use comm__namedPage instead.
Limitations
- The comm__loginPage pageReference type isn’t supported. Instead, navigate to the login page as a regular comm__namedPage.
- The objectApiName attribute is required when navigating to pages of type standard__recordPage or standard__recordRelationshipPage.
- The actionName attribute isn’t enforced as required when navigating to pages of type standard__recordPage or standard__recordRelationshipPage. However, including actionName remains a recommended best practice.