---
schema_version: "1"
id: def5ea9b975bbb225ebc424e85172bbffc93554f756a563488148c969d922096
title: navigate()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwr-node/lwr/references/csr-reference/navigate.md
canonical_url: https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/navigate.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 64948742523314f90e997ab3e97030867f6b3fe546d3b7dbdbd3afc8bdf02148
products:
  - Lightning Web Runtime
---
# 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`](https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/navigationcontext.md) wire. |
| `pageReference` | String  | Required          | The [`PageReference`](https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/pagereference.md) 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

```javascript
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**

- [Simple Client-Side Routing: Navigate](https://developer.salesforce.com/docs/platform/lwr/guides/lwr-routing-example-simple.md#navigate)
