Display an alert BEFORE router navigates (next app)?
Unanswered
Patterdale Terrier posted this in #help-forum
Patterdale TerrierOP
Hi, i'm banging my head against the wall trying to display a simple window.alert BEFORE the next/navigation takes place.
My desired behaviour is:
- On a route
- If a user clicks a link (which triggers router.push or uses next/link) anywhere on the page, the alert is displayed
This looks like it was possible in the pages directory with router.events
Am i missing something here?
My desired behaviour is:
- On a route
- If a user clicks a link (which triggers router.push or uses next/link) anywhere on the page, the alert is displayed
This looks like it was possible in the pages directory with router.events
routeChangeStart, but not with next/navigation, since the suggested way of listening to events with usePathname only fires AFTER the route has changed, disallowing us to hook into the event before?Am i missing something here?
1 Reply
Patterdale TerrierOP
To add further context,
beforeunload is being fired during browser reloading or hitting the back button, but not navigating away with the next apis mentioned