Next.js Discord

Discord Forum

How to prevent route from changing too quickly

Unanswered
Bhotia posted this in #help-forum
Open in Discord
Avatar
BhotiaOP
Hey everyone,

My website has a navbar on its root layout so it persists between route changes. I have happened users with rush try to change between routes too quickly (press a link on the navbar and then immediately press another) and this causes some weird behaviour: The contents of the page at the first route are rendered at the second route, and if I try to go to the first route again, it's just an empty page. And if I try to go to any other page besides the two in question, it's just the contents of the first page route without CSS.

So I was wondering if there is a way to always prevent the Next.js app from changing routes too quickly, or if I can implement something on my navbar that detects if a route change is happening before trying to change it.

(I should mention I have a page transition happening with Framer Motion that probably helps this being caused)

Thank you!

0 Replies