Next.js Discord

Discord Forum

How can i fetch data on server and pass the data to the client for app router?

Answered
Netherland Dwarf posted this in #help-forum
Open in Discord
Netherland DwarfOP
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.

export default async function ThisIsServerComponent() {
  const data = await fetchSomeData();

  return <div>
    <ThisIsClientComponent data={data} />
  </div>
}


Does that make sense?
View full answer

11 Replies

You fetch it inside the server component then pass it down to other components via props.

export default async function ThisIsServerComponent() {
  const data = await fetchSomeData();

  return <div>
    <ThisIsClientComponent data={data} />
  </div>
}


Does that make sense?
Answer
Netherland DwarfOP
thank you and yes i found an article on this too thanks!
great 🙂
Netherland DwarfOP
sorry
can i ask you another question
sure but if it's another problem you have better to open a new post
Netherland DwarfOP
hm ok
unless its related to this
Netherland DwarfOP
its different but
il open a new post
great, keeps the forum cleaner and more searchable 🙂