Slow Navigation between pages
Answered
Falah posted this in #help-forum
Original message was deleted.
Answered by riský
well, if its a link, you should use next/link instead of using onclick and then next/navigation (as prefetching and better ux with next/link)
15 Replies
This sort of delay is often encountered when using next dev (via yarn dev or npm dev). This is because when using yarn dev, page is rebuild every time it is requested. So when you navigate back to the index page, Next.js first rebuild that page for you and then it is served. That's why there is a delay.
You should not find similar delay in production (when using next build and then next start)
You should not find similar delay in production (when using next build and then next start)
Thanks @averydelusionalperson appriciated your resoponse
is this the right way to navigate between pages, what are the best practices to look for here
is this the right way to navigate between pages, what are the best practices to look for here
there aren't really any best practices in navigation?
U just navigate
either using link or router
@averydelusionalperson there aren't really any best practices in navigation?
well, if its a link, you should use next/link instead of using onclick and then next/navigation (as prefetching and better ux with next/link)
Answer
if the content is dynamic you can still use, its only imo when the outcome of link depends on press
if possible link, else router hook form 'next/navigation'
and in OP's code, i use asChild on the shadcn button (im guessing thats whats being used here) (but i can also assume they used router as next/link was also slow)
yeah, if I want shadcn button, I use asChild and use link too
thanks guys
mark the answer that helped you as solution