Introduction
TheNavigationMixin from lightning/navigation enables Lightning Web Components to navigate to different pages and records within Salesforce. It provides a consistent navigation experience across Lightning Experience, Salesforce Mobile App, and Communities.
NavigationMixin Basics
To use navigation in your component, extend your class withNavigationMixin:
PageReference Structure
Every navigation uses a PageReference object with the following structure:- type - The type of page to navigate to
- attributes - Key-value pairs that describe the page
- state - Additional parameters for the page (optional)
Navigation Types
Record Navigation
Navigate to record pages, create new records, and edit existing ones
Page Navigation
Navigate to home pages, named pages, and custom tabs
Navigation Utilities
Advanced navigation patterns including list views and related lists
Common PageReference Types
standard__recordPage
standard__recordPage
Navigate to a record’s view, edit, or clone page.Attributes:
recordId- The record IDobjectApiName- The API name of the objectactionName- ‘view’, ‘edit’, or ‘clone’
standard__objectPage
standard__objectPage
Navigate to an object’s home, list, or new record page.Attributes:
objectApiName- The API name of the objectactionName- ‘home’, ‘list’, or ‘new’
standard__namedPage
standard__namedPage
Navigate to standard Salesforce pages.Attributes:
pageName- ‘home’, ‘chatter’, or other named pages
standard__navItemPage
standard__navItemPage
Best Practices
Use
lightning/pageReferenceUtils to encode default field values when creating records with pre-populated data.Next Steps
Explore specific navigation patterns:- Record Navigation - Work with Salesforce records
- Page Navigation - Navigate to standard pages and tabs
- Navigation Utilities - Advanced navigation techniques
