Next.js Discord

Discord Forum

server action question

Unanswered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Southeastern blueberry beeOP
Hello, i have a small question: the doc say that we can use server action from server component but what I don't understand is that mutations are generally initiated by client-side events (clicks, etc.), events that are not managed by the server component. So my question is this: in which case should client-side server actions be privileged from server-side actions, and above all, how do server-side actions work? thank you

1 Reply

@Southeastern blueberry bee Hello, i have a small question: the doc say that we can use server action from server component but what I don't understand is that mutations are generally initiated by client-side events (clicks, etc.), events that are not managed by the server component. So my question is this: in which case should client-side server actions be privileged from server-side actions, and above all, how do server-side actions work? thank you
to break server actions down to describe them as simple as possible: server actions are just easier api endpoints. The docs they, they are:
... asynchronous functions that are executed on the server.
So yes, use them for mutations. Fetching data can still be handled serverside while loading a component