Loading....
save

Best practices for fetching data in React Server Components

clock icon

asked 2 months ago

message icon

3

eye icon

322

Should I use fetch directly in my component or use a library like TanStack Query? I heard RSCs can fetch directly.

Example:

1async function Page() {
2 const data = await getData();
3 return <div>{data.title}</div>
4}
1async function Page() {
2 const data = await getData();
3 return <div>{data.title}</div>
4}

Is this okay for production?

3 Answers

1

Please log in to answer this question

Top Questions