-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Blocking navigation #2236
Comments
You can use browser's inbuilt |
Sorry, I should have said that I've already tried that :) The following snippet works fine if a user hits back etc., but does nothing if they navigate away by clicking any links within the site.
|
Good point. |
I'm willing to accept an example of this in the repo 👌 |
Actually, we may need some core support for that as well at some point. |
I think we should be able to allow the routing to be stopped if user returns false in the callback function. such like Router.onRouteChangeStart = () => {
if (/*should not leave the page*/) {
return false;
} else {
return true;
}
} Or adding another event that gets triggered before the transition starts to allow user halt the transition, e.g. |
Closing in favor of #2694 |
I have a Next.js app with an editor page, and would like to warn users about unsaved changes if they try and navigate away. React Router offers a handy prompt component - is there a way to achieve something similar in Next?
The text was updated successfully, but these errors were encountered: