Development questions

How do you navigate to a record page or another page from an LWC?

DevelopmentEasy

Use NavigationMixin from lightning/navigation:

javascript
import { NavigationMixin } from 'lightning/navigation';

export default class Nav extends NavigationMixin(LightningElement) {
  goToRecord() {
    this[NavigationMixin.Navigate]({
      type: 'standard__recordPage',
      attributes: { recordId: this.recordId, actionName: 'view' }
    });
  }
}

Common type values: standard__recordPage, standard__objectPage, standard__webPage, standard__navItemPage, comm__namedPage (Experience Cloud). Use GenerateUrl to get a URL instead of navigating.

lwcnavigation