lightning/navigation service. This component demonstrates navigating to both view and edit modes.
Source
force-app/main/default/lwc/navToRecord/navToRecord.js
Usage
NavigationMixin
Extend your component withNavigationMixin to access navigation capabilities:
PageReference
View Record
Set to
standard__recordPage for record pagesThe ID of the record to display
The API name of the object (e.g., ‘Contact’, ‘Account’)
Set to
view to display the record in view modeEdit Record
Set to
standard__recordPage for record pagesThe ID of the record to edit
The API name of the object (e.g., ‘Contact’, ‘Account’)
Set to
edit to display the record in edit modeKey Features
- Navigate to record view pages
- Navigate to record edit pages
- Type-safe navigation with PageReference
- Supports all standard and custom objects
