Next.js Discord

Discord Forum

Poor API condition and late data fetching

Answered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
Hello everyone, Im facing some issues with my API responses.
I would like to fetch from API only first 20 records (because fetching all of them is really slow) in buildtime, and fetch rest of them on client side (meaning when user renders this component).
Scenario:
1. During buildtime im making a request for first 20 items
2. During component render I would like to show first 20 that are prefetched with some loader below and start fetching rest of them.

The question is:
Should I use server-actions in "use client" component? I cant really cache all the results, because they must be up-to-date (even ignoring the first 20 that are prefetched). Or how should I solve this issue?
Answered by Barbary Lion
Suspense used, closing.
View full answer

1 Reply

Barbary LionOP
Suspense used, closing.
Answer