Next.js Discord

Discord Forum

Question about useRouter

Unanswered
gin posted this in #help-forum
Open in Discord
ginOP
So useRouter exposes the back() function which is very useful but i was thinking if there is a way to get the router history so i can dynamically trigger functions based on if the client navigated from a specific path

2 Replies

ginOP
or should i just go for the primitive way and save the current path to a state and check for that on pathname change
You cant access the in browser history. You can access the request object and see where the 'referer' is though