Fetch on server component and client component - best pattern
Unanswered
West African Lion posted this in #help-forum
West African LionOP
Based on next js docs the closer we fetch data to the components the better.
So, I have page that has 4 main components, all of those components consume the same data.
I also need to fetch data every 15 seconds on client side.
Whats the best approach here using server component fetching + RQ?
should those 4 components being wrapped by server components that fetch the data on the server and then RQ gets the initial Data and fetches the data on a client component?
Should each component get wrapped by one server component each to fetch the data?
Next + RQ has so many different patterns that I dont know how I should do this. Appreciate some Guidance, most use cases of new next features are always dashboards or todo lists that dont need to fetch in realtime so Im just confused
So, I have page that has 4 main components, all of those components consume the same data.
I also need to fetch data every 15 seconds on client side.
Whats the best approach here using server component fetching + RQ?
should those 4 components being wrapped by server components that fetch the data on the server and then RQ gets the initial Data and fetches the data on a client component?
Should each component get wrapped by one server component each to fetch the data?
Next + RQ has so many different patterns that I dont know how I should do this. Appreciate some Guidance, most use cases of new next features are always dashboards or todo lists that dont need to fetch in realtime so Im just confused
1 Reply
My suggestion is using react-query and passing data that was fetched on server as initialData