Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the Navigation API #1415

Closed
LifeIsStrange opened this issue May 25, 2022 · 2 comments
Closed

Support the Navigation API #1415

LifeIsStrange opened this issue May 25, 2022 · 2 comments

Comments

@LifeIsStrange
Copy link

What problem does this feature solve?

Chromium 102 has been released stable, which means that Chrome, Edge, Opera, Brave, Vivaldi, etc and Electron supports the Navigation API
https://chromestatus.com/feature/6232287446302720
The Navigation API is the successor of the History API and is better suited for SPAs.
Therefore, routers should allow to target and leverage it.

Why should this feature be included?

The existing window.history API is hard to deal with in practice, especially for single-page applications. In the best case, developers can work around this with various hacks. In the worst case, it causes user-facing pain in the form of lost state and broken back buttons, or the inability to achieve the desired navigation flow for a web app.

What does the proposed API look like?

see the spec https://chromestatus.com/feature/6232287446302720

@posva
Copy link
Member

posva commented May 25, 2022

I'm aware and active in the open discussion of the API and it's still too early to adopt. It will be adopted possible.

@posva posva closed this as completed May 25, 2022
@zkulbeda
Copy link

zkulbeda commented Jul 9, 2023

Hi @posva, it seems Navigation API was successfully merged into html spec (whatwg/html#8502). Is it worth to reopen the issue? This API offers a completely different way to manage user navigation and some advantages such as

  • Native page loading state
  • Native aborted navigations (with AbortSignal)
  • Native scroll position restoration
  • Setting the entry's state without navigating
  • Native canceling of the navigation (i. e. without need to go back on cancel)

The current architecture of the router based on listening to history events does not allow you to create a new history adapter that would listen to the end of navigation using promises and notify the browser of the end. And also how navigation cancellation is implemented inside router instance, it's impossible for the adapter to know that navigation is cancelled. It's hard to imagine how many changes will have to be made to the existing solution, maybe it worth writing version 5.0.0 of the package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants