This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Navigation interface of the Navigation API allows control over all navigation actions for the current window in one central place, including initiating navigations programmatically, examining navigation history entries, and managing navigations as they happen.
It is accessed via the Window.navigation property.
The Navigation API only exposes history entries created in the current browsing context that have the same origin as the current page (e.g., not navigations inside embedded <iframe>s, or cross-origin navigations), providing an accurate list of all previous history entries just for your app. This makes traversing the history a much less fragile proposition than with the older History API.
Inherits properties from its parent, EventTarget.
activation Read only Experimental
Returns a NavigationActivation object containing information about the most recent cross-document navigation, which "activated" this Document.
canGoBack Read only Experimental
Returns true if it is possible to navigate backwards in the navigation history (i.e., the currentEntry is not the first one in the history entry list), and false if it is not.
canGoForward Read only Experimental
Returns true if it is possible to navigate forwards in the navigation history (i.e., the currentEntry is not the last one in the history entry list), and false if it is not.
currentEntry Read only Experimental
Returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.
transition Read only Experimental
Returns a NavigationTransition object representing the status of an in-progress navigation, which can be used to track it. Returns null if no navigation is currently in progress.
Inherits methods from its parent, EventTarget.
back() Experimental
Navigates backwards by one entry in the navigation history.
entries() Experimental
Returns an array of NavigationHistoryEntry objects representing all existing history entries.
forward() Experimental
Navigates forwards by one entry in the navigation history.
Navigates to a specific URL, updating any provided state in the history entries list.
reload() Experimental
Reloads the current URL, updating any provided state in the history entries list.
traverseTo() Experimental
Navigates to a specific NavigationHistoryEntry identified by key.
updateCurrentEntry() Experimental
Updates the state of the currentEntry; used in cases where the state change will be independent from a navigation or reload.
Inherits events from its parent, EventTarget.
currententrychange Experimental
Fired when the Navigation.currentEntry has changed.
Fired when any type of navigation is initiated, allowing you to intercept as required.
Fired when a navigation fails.
Fired when a successful navigation has finished.
async function backHandler() {
if (navigation.canGoBack) {
await navigation.back().finished;
// Handle any required clean-up after
// navigation has finished
} else {
displayBanner("You are on the first page");
}
}
async function forwardHandler() {
if (navigation.canGoForward) {
await navigation.forward().finished;
// Handle any required clean-up after
// navigation has finished
} else {
displayBanner("You are on the last page");
}
}
// On JS startup, get the key of the first loaded page
// so the user can always go back there.
const { key } = navigation.currentEntry;
backToHomeButton.onclick = () => navigation.traverseTo(key);
// Navigate away, but the button will always work.
await navigation.navigate("/another_url").finished;
navigation.navigate(url, { state: newState });
Or
navigation.reload({ state: newState });
Or if the state is independent from a navigation or reload:
navigation.updateCurrentEntry({ state: newState });
| Specification |
|---|
| HTML> # navigation-interface> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Navigation |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
activation |
123 | 123 | No | 109 | No | 123 | No | 82 | No | 27.0 | 123 | No |
back |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
canGoBack |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
canGoForward |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
currentEntry |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
currententrychange_event |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
entries |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
forward |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
navigate |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
navigate_event |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
navigateerror_event |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
navigatesuccess_event |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
reload |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
transition |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
traverseTo |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
updateCurrentEntry |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigation