Next.js Discord

Discord Forum

next/navigation router is slow

Unanswered
Pacific cod posted this in #help-forum
Open in Discord
Pacific codOP
Hi the next/navigation router is slow.. on router.push operation it takes around 1 second to propogate.

37 Replies

@Pacific cod Hi the next/navigation router is slow.. on router.push operation it takes around 1 second to propogate.
does it happen only at the first time you navigate, or does it happens everytime?
@alfon does it happen only at the first time you navigate, or does it happens everytime?
Pacific codOP
everytime it happens the same
did you try spamming it or did you try it, every now and then?
is it on prod or dev?
Pacific codOP
i have a dashboard page which needs to be shown on login... so without login i router.push to login page.. also i show a loading screen when the login data is being checked
now i see the dashboard for 1 sec before propogating
@alfon is it on prod or dev?
Pacific codOP
both
@alfon did you try spamming it or did you try it, every now and then?
Pacific codOP
every time
maybe that 1 sec is because you need to await fetching the session object on the client
if you don't want that maybe put the fetch session object on the server instead
Pacific codOP
no fetching data has loading screen
when it was with pages directoy it was working ggood
no fetching data has loading screen
or
no, fetching data has loading screen
Pacific codOP
i migrated it to app now
i still believe its something that happens in the client.
something is being initialized with useEffect
@alfon no fetching data has loading screen or no, fetching data has loading screen
Pacific codOP
when user information is being loaded.. loading indicator is being showed
otherwise it won't flash the content if its being handled server-side
does the loading screen worked?
@alfon otherwise it won't flash the content if its being handled server-side
Pacific codOP
yes but after migration to app directory im facing this issue
@alfon does the loading screen worked?
Pacific codOP
yes
i feel the router propogation is delayed
does the URL change instantly after router.push
im not sure how you set it up in pages router and how you would've migrated it to app dir
Pacific codOP
url dosent change quickly
well what auth lib are you using
@alfon well what auth lib are you using
Pacific codOP
it shouldnt cause any issues bec when there is no user in the useState
the router.push will take place
it might be because of whatever happened before router.push
how are you sure that router.push is the cause of the delay
Pacific codOP
router push only happens when loading:false and user:null
loading:true showing loading indicator
@alfon how are you sure that router.push is the cause of the delay
Pacific codOP
bec before migration the app was running smooth
thats a not so valid reason, you still take responsibility of the code you write. so you must've known if router.push would be the case of the delay
regardless, im not sure what your problem is, maybe try creating a reproducible repository, so that we can understand it better
Pacific codOP
my bad
i didnt return the <Loader /> component while migrating
so there was a glitch