Developer Preview Feature
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
You can use NavigationMixin instead of the navigate() and generateUrl() APIs. Both options offer the same functionality, but only NavigationMixin is compatible with Lightning Experience. If you’re writing a component for use in both LWR and Lightning Experience, choose NavigationMixin.
1import { LightningElement } from "lwc";
2import { NavigationMixin } from "lightning/navigation";
3
4const pageRef = {
5 type: "standard__recordPage",
6 attributes: {
7 recordId: "001xx000003DGg0AAG",
8 objectApiName: "Account",
9 actionName: "view",
10 },
11};
12
13export default class Example extends NavigationMixin(LightningElement) {
14 // Navigate to a page reference
15 navPageRef() {
16 this[NavigationMixin.Navigate](pageRef);
17 }
18 // Generate a URL for a page reference
19 getUrl() {
20 this[NavigationMixin.GenerateUrl](pageRef).then((url) => console.log(url));
21 }
22}See Also
Developer Preview Feature