equivalent to routeChangeStart with app router
Unanswered
English Mastiff posted this in #help-forum
English MastiffOP
Wondering whats the equivalent to routeChangeStart with the new app router. using
usePathname is not sufficient because its when the route was already loaded, I need to listen to the event that is triggered when the change is triggered. Couldn't find anything in the migration guide about it and listening to popstate event doesnt work either. Any suggestions?3 Replies
I'm not sure why the events were removed but i guess its mostly because the navigation is now supposed to be almost instant.
I don't know how good of a idea this is, but if you are using this with Link then you can probably just replace the behavior with onClick. Although im not sure how much of a help that will be
I don't know how good of a idea this is, but if you are using this with Link then you can probably just replace the behavior with onClick. Although im not sure how much of a help that will be
(I have never tried this stuff so im just throwing an arrow in the dark)
English MastiffOP
jeah thats the other consideration. i dont like so much to have additional onclick handlers on anchors. the routechangestart api was pretty elegant for that 🙂