Can I have loading state in SSR pages?
Unanswered
Vikhan posted this in #help-forum
VikhanOP
Hi!
I have a deployed website with nextjs and SSR.
The thing is, sometimes it takes half a second to change the page (because Its fetching data server side).
Is there any way to have a loading state when Im going to ssr pages?
Im using next 13.4.something but with the pages router
I have a deployed website with nextjs and SSR.
The thing is, sometimes it takes half a second to change the page (because Its fetching data server side).
Is there any way to have a loading state when Im going to ssr pages?
Im using next 13.4.something but with the pages router
17 Replies
Shy Albatross
use Links with prefetch, generate pages ahead of time or move more stuff to frontend because too much SSR can be terrible UX, like you just noticed
because im reading the docs
and prefetch is default to true
Shy Albatross
is it prefetching? if not, then why?
VikhanOP
I mean, this is what the docs say:
Defaults to true. When true, next/link will prefetch the page (denoted by the href) in the background
Defaults to true. When true, next/link will prefetch the page (denoted by the href) in the background
Meaning, prefetching is already enabled
Should I disable it then?
Shy Albatross
yes, it defaults to true, does it work? do you see the prefetch happening, why is it taking so long to change a page if it was prefetched?
you should see the request for prefetch when you visit the page that has a Link to a particular page that's being prefetched
I'll keep investigating
Shy Albatross
if you're running the app in terminal via
run dev you'd see requests for those prefetched pagessay yo're on the index page
/ and you have a Link to /blog on the home page, then you go to / in browser you'd see Next logging out that it's compiling /, then once the Link kicks in, which is client-side JS, you'd see a request for /blogbecause Link would be prefetching that page
VikhanOP
Going to the network tab anda going to an ssr page with Link shows "fetch" no "prefetch"
Project is already deployed aswell