Navigation: navigate() method

Baseline 2026
Newly available

Since January 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The navigate() method of the Navigation interface navigates to a specific URL, updating any provided state in the history entries list.

Syntax

js
navigate(url)
navigate(url, options)

Parameters

url

The destination URL to navigate to. Note that when calling navigate() on another window's navigation object, the URL will be resolved relative to the target window's URL, not the calling window's URL. This matches the behavior of the History API, but not the behavior of the Location API. Note also that javascript: URLs are not allowed for security reasons.

options Optional

An options object containing the following properties:

state Optional

Developer-defined information to be stored in the associated NavigationHistoryEntry once the navigation is complete, retrievable via getState(). This can be any data type. You might, for example, wish to store a page visit count for analytics purposes, or store UI state details so the view can be shown exactly as the user last left it. Any data stored in state must be structured-cloneable.

info Optional

Developer-defined information to be passed along to the navigate event, made available in NavigateEvent.info. This can be any data type. You might, for example, wish to display newly-navigated content with a different animation depending on how it was navigated to (swipe left, swipe right, or go home). A string indicating which animation to use could be passed in as info.

history Optional

An enumerated value that sets the history behavior of this navigation. The available values are:

  • auto: The default value; will usually perform a push navigation but will perform a replace navigation under special circumstances (see the NotSupportedError description below).
  • push: Will push a new NavigationHistoryEntry onto the entries list, or fail under special circumstances (see the NotSupportedError description below).
  • replace: Will replace the current NavigationHistoryEntry.

Return value

An object with the following properties:

committed

A Promise which will fulfill when the visible URL has changed and a new NavigationHistoryEntry has been created.

finished

A Promise which will fulfill when all promises returned by the intercept() handler are fulfilled. This is equivalent to the NavigationTransition.finished promise fulfilling, when the navigatesuccess event fires.

Either one of these promises rejects if the navigation has failed for some reason.

Exceptions

DataCloneError DOMException

Thrown if the state parameter contains values that are not structured-cloneable.

InvalidStateError DOMException

Thrown if the document is not currently active.

SyntaxError DOMException

Thrown if the url parameter is not a valid URL.

NotSupportedError DOMException

Thrown if:

  • The history option is set to push, and the browser is currently showing the initial about:blank document.
  • The url's scheme is javascript.

Examples

Set up home button

js
function initHomeBtn() {
  // Get the key of the first loaded entry
  // so the user can always go back to this view.
  const { key } = navigation.currentEntry;
  backToHomeButton.onclick = () => {
    navigation.traverseTo(key);
  };
}
// Intercept navigate events, such as link clicks, and
// replace them with single-page navigations
navigation.addEventListener("navigate", (event) => {
  event.intercept({
    async handler() {
      // Navigate to a different view,
      // but the "home" button will always work.
    },
  });
});

A smart back button

A page-supplied "back" button can take you back, even after reload, by inspecting the previous history entries:

js
backButtonEl.addEventListener("click", () => {
  if (
    navigation.entries()[navigation.currentEntry.index - 1]?.url ===
    "/product-listing"
  ) {
    navigation.back();
  } else {
    // If the user arrived here in some other way
    // e.g. by typing the URL directly:
    navigation.navigate("/product-listing", { history: "replace" });
  }
});

Using info and state

js
async function navigateHandler() {
  await navigation.navigate(url, {
    info: { animation: "swipe-right" },
    state: { infoPaneOpen: true },
  }).finished;

  // Update application state
  // …
}

Specifications

Specification
HTML
# dom-navigation-navigate-dev

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
navigate
Chrome – Full support
Chrome 102 (Release date: 2022-05-24)
footnote
footnote Chrome allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
Edge – Full support
Edge 102 (Release date: 2022-05-31)
footnote
footnote Edge allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
Firefox – Full support
Firefox 147 (Release date: 2026-01-13)
footnote Full support
Opera – Full support
Opera 88 (Release date: 2022-06-08)
footnote
footnote Opera allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
Safari – Full support
Safari 26.2 (Release date: 2025-12-12)
footnote Full support
Chrome Android – Full support
Chrome Android 102 (Release date: 2022-05-24)
footnote
footnote Chrome Android allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
Firefox for Android – Full support
Firefox for Android 147 (Release date: 2026-01-13)
footnote Full support
Opera Android – Full support
Opera Android 70 (Release date: 2022-06-29)
footnote
footnote Opera Android allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
Safari on iOS – Full support
Safari on iOS 26.2 (Release date: 2025-12-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 19 (Release date: 2022-11-01)
footnote
footnote Samsung Internet allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
WebView Android – Full support
WebView Android 102 (Release date: 2022-05-24)
footnote
footnote WebView Android allows javascript: URLs when calling navigate(), contrary to the specification (bug 439994590).
WebView on iOS – Full support
WebView on iOS 26.2 (Release date: 2025-12-12)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

See also