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

Expose a configurable beforeunload api from the router. #344

Closed
samccone opened this issue Jan 24, 2021 · 2 comments
Closed

Expose a configurable beforeunload api from the router. #344

samccone opened this issue Jan 24, 2021 · 2 comments
Labels
feature request New feature or request

Comments

@samccone
Copy link
Contributor

When building an application that has page state (such as uploads), it can be powerful to be able to prompt the user before they leave the page. In traditional web apps we are able to use beforeunload in order to warn / prompt the user.

In SPA land however we need to implement something similar for in app navigation. Currently the router https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/internal/router/index.js does not expose hooks like this

Looking at prior art react-router has a concept of a Prompt
https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/Prompt.md

Ember has a concept of a route willTransition
https://guides.emberjs.com/release/routing/preventing-and-retrying-transitions/

Backbone has the ability to return false from execute
https://backbonejs.org/#Router-route

@benmccann
Copy link
Member

Yeah, this seems like a good idea. @antony had a request for this as well in Sapper: https://github.com/sveltejs/sapper/issues/1278

@benmccann benmccann added the feature request New feature or request label Mar 3, 2021
@benmccann
Copy link
Member

I transferred the other issue to this repo so that we don't lose the conversation history. Closing this one as a duplicate of the other: #552

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

No branches or pull requests

2 participants