How can i fetch data on server and pass the data to the client for app router?
Answered
American Chinchilla posted this in #help-forum
American ChinchillaOP
How can i fetch data on server and pass it the client if i cant use getServerProps or use hooks on server?
Answered by josh
You fetch it inside the server component then pass it down to other components via props.
Does that make sense?
export default async function ThisIsServerComponent() {
const data = await fetchSomeData();
return <div>
<ThisIsClientComponent data={data} />
</div>
}
Does that make sense?
11 Replies
You fetch it inside the server component then pass it down to other components via props.
Does that make sense?
export default async function ThisIsServerComponent() {
const data = await fetchSomeData();
return <div>
<ThisIsClientComponent data={data} />
</div>
}
Does that make sense?
Answer
American ChinchillaOP
thank you and yes i found an article on this too thanks!
great 🙂
American ChinchillaOP
sorry
can i ask you another question
sure but if it's another problem you have better to open a new post
American ChinchillaOP
hm ok
unless its related to this
American ChinchillaOP
its different but
il open a new post
great, keeps the forum cleaner and more searchable 🙂