Data fetching in NextJs 13.4+

I have a question about this statement - In this new model, we recommend fetching data directly in the component that needs it, even if you're requesting the same data in multiple components, rather than passing the data between components as props. I thought the server component paradigm was fetch in a server component and pass the data to the client component leaves. As a simple example, say you were populating a drop down list from an api call. I assumed the server component would request the data and pass it into whatever client component is going to create the interactive list. Is that the wrong way to think about it? Are fetch requests only cached if implemented inside of a server component? I've read the nextjs docs and I feel they make assumptions about some of the underlying concepts. Small thing, are components outside of the app folder default server components as well or do they have to be within the app directory?
3 Replies
cje
cje2y ago
What they mean by this is don’t worry about requesting the same thing in two different places Passing from a server to a client component is fine And yes if you import a component from a different folder it will still be RSC by default
nonstoppants
nonstoppantsOP2y ago
Thanks so much for the response.
Neto
Neto2y ago
rsc big selling point is giving you plain html so you can use react as a mechanism to create html if you use get server side props, you are processing the request to when the page render you have the necessary data already there main issue is that you still have to run in the react lifecycle, hydration and the issues related to that
Want results from more Discord servers?
Add your server