Next.js Discord

Discord Forum

Data fetch in Next 15 with Server Actions

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Avatar
Masai LionOP
What's the most recommended way to fetch data with server actions? It's to use a client side library like react-query and pass the server actions to return the data or fetching the data in the server side and prop drilling to the components?

I am really confused because I see myself performing actions with Server Actions but not fetching data, so I would like to hear a little bit more if I am missing something.

3 Replies

Avatar
Masai LionOP
by the way I don't fetch data over http, I don't intend to use http calls neither rpc calls (trpc)
Avatar
Masai LionOP
so it's all about fetching in the server components and prop drilling? if there are mutations to the data, then we should revalidatePath?
Avatar
Polar bear
The recommended solution is... to not use server actions for data fetching. Check your network and you'll see server actions are always post requests.

You can do the whole dehydration thing then rehydrate and pass it as initial values to react query.. horrible implementation if you ask me.

Best bet is, server component, fetch the data then pass the data as props to client component.