#show dialog on navigation?

1 messages · Page 1 of 1 (latest)

glossy axle
#

currently I'm using next.js with app router and have several pages with form, is there a way to handle event window.onbeforeunload when user want to leave page if form data was changed?

soft ploverBOT
#

Hi @glossy axle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. The provided extracts do not contain specific information about handling the window.onbeforeunload event when form data changes in Next.js with the App Router.

However, you can generally use the window.onbeforeunload event in JavaScript to execute code when a user is about to leave a webpage. This can be used to warn users about unsaved changes in a form.

For more specific guidance on how to implement this in Next.js, I recommend checking the Next.js documentation (https://nextjs.org/docs) or relevant resources on handling browser events in React.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@glossy axle kapa.ai is still learning and improving, please let us know how it did by reacting below