Data fetching strategy
Using nextjs 15 app dir do you fetch on server components, use react query for example to fetch on client or prefetch on server component and hydrate to client using react-query?
I am so used to fetch using react-query so thinking if i should change my idealogy:
I have app that is behind auth, just forms etc, tables (paginated) and in my brains its better to prefetch+react-query suspensequery for clientside
i have hono endpoints on top of my nextjs app that are protected and i use honorpc
2 Replies
So basically trying to understand what is the difference between fetching on server component with that component wrapped to suspense vs my strategy (prefetch+hydrate on client+suspense query)
The main benefit between server side fetching and client side fetching on next js is caching (server side/client side).
You can use the benefit of speed of server to do heavy fetching like blogs (subjective), computations etc
Client side fetching is to pass on the load to user with lighter fetching.
These are generalizations and not a go to all solutions