navigate()

Navigates to a page reference programmatically.

Properties 

Method InputTypeRequired/OptionalDescription
contextStringRequiredThe 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.
pageReferenceStringRequiredThe PageReference value for which to generate a URL.
replaceBooleanOptionalIf set to true, navigate() replaces the current history entry with the location passed in the method parameters.

Syntax 

1import { LightningElement, api, wire } from 'lwc';
2import { NavigationContext, navigate } from 'lwr/navigation';
3import type { ContextId, PageReference } from 'lwr/navigation';
4
5navigate(
6    context: ContextId,
7    pageReference: PageReference,
8    replace?: boolean
9    ): void

Returns 

  • None

See Also

Developer Preview Feature

Feature is available as a developer preview. Feature is not generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All commands, parameters, and other features are subject to change or deprecation at any time, with or without notice. Do not implement functionality developed with these commands or tools.

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!