The Navigation API modern browsers
Use the Navigation API to intercept and customize navigations.
A Modern Replacement
The Navigation API is a newer, more powerful replacement for the History API. It treats navigations as first-class objects you can intercept, abort, and await — closer to how SPAs actually need to handle routing in 2024.
window.navigation Object
window.navigation exposes the entry list, the current entry, and the navigate event. navigation.entries() returns every entry in the current history; navigation.currentEntry is the active one. Compare to History API's opaque length and unread state.
All lessons in this course
- pushState and replaceState
- The popstate Event
- Hash-Based vs Path-Based Routing
- The Navigation API modern browsers