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 NavigationDestination interface of the Navigation API represents the destination being navigated to in the current navigation.
It is accessed via the NavigateEvent.destination property.
id Read only Experimental
Returns the id value of the destination NavigationHistoryEntry if the NavigateEvent.navigationType is traverse, or an empty string otherwise.
index Read only Experimental
Returns the index value of the destination NavigationHistoryEntry if the NavigateEvent.navigationType is traverse, or -1 otherwise.
key Read only Experimental
Returns the key value of the destination NavigationHistoryEntry if the NavigateEvent.navigationType is traverse, or an empty string otherwise.
sameDocument Read only Experimental
Returns true if the navigation is to the same document as the current Document value, or false otherwise.
url Read only Experimental
Returns the URL being navigated to.
getState() Experimental
Returns a clone of the available state associated with the destination NavigationHistoryEntry, or navigation operation (e.g., navigate()) as appropriate.
navigation.addEventListener("navigate", (event) => {
// Exit early if this navigation shouldn't be intercepted,
// e.g. if the navigation is cross-origin, or a download request
if (shouldNotIntercept(event)) {
return;
}
// Returns a URL() object constructed from the
// NavigationDestination.url value
const url = new URL(event.destination.url);
if (url.pathname.startsWith("/articles/")) {
event.intercept({
async handler() {
// The URL has already changed, so show a placeholder while
// fetching the new content, such as a spinner or loading page
renderArticlePagePlaceholder();
// Fetch the new content and display when ready
const articleContent = await getArticleContent(url.pathname);
renderArticlePage(articleContent);
},
});
}
});
| Specification |
|---|
| HTML> # the-navigationdestination-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 | |
NavigationDestination |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
getState |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
id |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
index |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
key |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
sameDocument |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
url |
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/NavigationDestination