Next.js: Preventing page transitions.

Created on 25 May 2018  路  3Comments  路  Source: vercel/next.js

Is it possible to do something like this: https://reacttraining.com/react-router/web/example/preventing-transitions with Nextjs ?

Most helpful comment

I have a form on my site and on a route change I'd like to display a prompt if the form has unsaved changes. There's no way I see I can accomplish this in Next.js at the moment. And like @Tomekmularczyk said, even if I wrote a custom Link (which would be hard because I use next-routes) it would still not handle browser history events.

All 3 comments

Yes, it's possible, but you'd have to implement it yourself with a custom Link component.

But I believe it would not work with browser "back" button.

I have a form on my site and on a route change I'd like to display a prompt if the form has unsaved changes. There's no way I see I can accomplish this in Next.js at the moment. And like @Tomekmularczyk said, even if I wrote a custom Link (which would be hard because I use next-routes) it would still not handle browser history events.

Was this page helpful?
0 / 5 - 0 ratings