How-to handle unsaved page changes with NextJS app router

Jon James
7 min readJan 30, 2024

The problem

At time of writing, many of the router.events — such as routeChangeStart()— that exist in the pages router of NextJS, are not currently available with the new app router.

There are many discussion threads on GitHub covering this issue, but at this time, the official docs don’t provide a clear way of preventing page…

--

--

Jon James

https://jonjames.io — Senior Frontend Developer and Digital Designer; Expert in React, React Native and UI Design.