Next.js Discord

Discord Forum

Slow navigation because of slow api

Answered
Blanc de Hotot posted this in #help-forum
Open in Discord
Avatar
Blanc de HototOP
I have to use an external API that I can't improve a bit (2–3 second delays). SEO guy is angry at me. Because it leads to slow navigation, and slow navigation has a negative impact on SEO.

It's possible to create the illusion that slow API works fast via optimistic UI. Usualy it's used for like buttons or comment forms. Can it be used for navigation?

P.S
We cannot use prefetching due to business requirements.
Answered by B33fb0n3
yes, you can wrap your page inside a suspense boundary, that is pre generated during build time and will be instantly visible when navigating to a specific path.

Like that your page is directly visible and after the loading of your external API is done, the full site will be visible
View full answer

5 Replies

Avatar
yes, you can wrap your page inside a suspense boundary, that is pre generated during build time and will be instantly visible when navigating to a specific path.

Like that your page is directly visible and after the loading of your external API is done, the full site will be visible
Answer
Avatar
@Blanc de Hotot solved?
Avatar
Blanc de HototOP
yes, thanks
Avatar
sure thing
Avatar
Blanc de HototOP
To be honest, I faced that problem a few years ago and already solved it. I sought assistance to gather feedback on this approach.

Recently, I made a starter that heavily utilized the idea of optimistic navigation to deliver the best UX.
https://www.reddit.com/r/nextjs/comments/1g6ktz2/i_made_a_starter_with_perfect_navigation/

I'll try your approach for app router app, thanks for your response!