Next.js Discord

Discord Forum

Delay when loading a lot of data & navigating app

Answered
Florida White posted this in #help-forum
Open in Discord
Florida WhiteOP
When I am navigating through my app sometimes I have a huge delay. Specially on two pages where a lot of data is fetched.

For each page I have a server component to get the data and a client component for the interactive part.

*I had a useSearchParams error yesterday, in order to fix it I have put my children in layout.tsx in a Suspense tag.

My idea was it to add pagination or infinite scroll to these huge pages to fix the delay.

Are there better ways ?
Answered by Yi Lon Ma
no, you need to add loading.tsx file
View full answer

9 Replies

and if you are trying to navigate to same page but with diff query params, say /products?page=1, /products?page=2 then you need to add a unique key in that suspense boundary
<Suspense key={`products-${page}`}/>
like this
Florida WhiteOP
Right, I have a loading as a component which I already give the suspense in the layout. Should I add a suspense to each client component too? Is that what you saying ?
Answer
next will wrap your page in that suspense boundary
Florida WhiteOP
Okay, I will try out