Developer Preview Feature
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
Generates a URL for a specified page reference.
| Method Input | Type | Required/Optional | Description |
|---|---|---|---|
context | String | Required | The ID of the parent router container nearest to the component that’s generating a URL. A ContextId is an opaque value that you get from the NavigationContext wire. |
pageReference | String | Required | The PageReference value for which to generate a URL. |
1import { LightningElement, api, wire } from 'lwc';
2import { NavigationContext, generateUrl } from 'lwr/navigation';
3import type { ContextId, PageReference } from 'lwr/navigation';
4
5generateUrl(
6 context: ContextId,
7 pageReference: PageReference
8 ): string | nullpageReference is valid, generateUrl() returns a string with the generated URL for the specified route.pageReference is invalid, it returns null.context is invalid, generateUrl() fails.See Also
Developer Preview Feature