Next.js Discord

Discord Forum

Passing Data To Children

Answered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
In SvelteKit you are able to pass down data from a layout and able to access it from any child of that layout in the app. I know SvleteKit does stuff behind the scenes to make this work but was wondering if this is something I am able to do with NextJS. Or when I want to fetch for user sessions should I just do it in every component that needs it instead of passing it down?
Answered by aardani
yes you should do it in every component since fetch() is ALREADY deduped
View full answer

3 Replies

to pass data, you simply call the getter function in multiple places and have it deduped. This creates the illusion of server "context"
yes you should do it in every component since fetch() is ALREADY deduped
Answer
Asian black bearOP
ahh ok