Skip to main content

Introduction

The NavigationMixin 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. To use navigation in your component, extend your class with NavigationMixin:
import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';

export default class MyComponent extends NavigationMixin(LightningElement) {
    navigateToPage() {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: '001xx000003DGBaAAO',
                objectApiName: 'Contact',
                actionName: 'view'
            }
        });
    }
}

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)

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

Navigate to a record’s view, edit, or clone page.Attributes:
  • recordId - The record ID
  • objectApiName - The API name of the object
  • actionName - ‘view’, ‘edit’, or ‘clone’
Navigate to an object’s home, list, or new record page.Attributes:
  • objectApiName - The API name of the object
  • actionName - ‘home’, ‘list’, or ‘new’
Navigate to standard Salesforce pages.Attributes:
  • pageName - ‘home’, ‘chatter’, or other named pages
Navigate to a custom tab.Attributes:
  • apiName - The API name of the custom tab

Best Practices

Always import NavigationMixin from lightning/navigation and apply it to your component class before using navigation methods.
Navigation will fail if the user doesn’t have permission to access the target page or record.
Use lightning/pageReferenceUtils to encode default field values when creating records with pre-populated data.

Next Steps

Explore specific navigation patterns:

Build docs developers (and LLMs) love