navigate()

Navigates to a page reference programmatically.

Properties

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.
replace Boolean Optional If set to true, navigate() replaces the current history entry with the location passed in the method parameters.

Syntax

import { LightningElement, api, wire } from 'lwc';
import { NavigationContext, navigate } from 'lwr/navigation';
import type { ContextId, PageReference } from 'lwr/navigation';

navigate(
    context: ContextId,
    pageReference: PageReference,
    replace?: boolean
    ): void

Returns

  • None

See Also