https://web.dev/blog/baseline-navigation-api?hl=en
The Navigation API radically simplifies this. It gives you a single, centralized NavigateEvent for every navigation—whether it's a user clicking a link, submitting a form, hitting the back button, or your code calling navigation.navigate().
The event.intercept() function does a lot of the heavy lifting for you: ...
https://web.dev/blog/baseline-navigation-api?hl=en