Next.js Discord

Discord Forum

server action vs server component ?

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
I don't get why a server component with an async funtion inside of it differs from a "user server" function ? won't they both execute on the server ?

5 Replies

Nile Crocodile
yes but difference is that if you have a "use server" function outside of a component
you can also just call it in client component
which will make an RPC call to that function
whereas you cannot do that to a function inside of a component since its scoped to that component
Server Component = a GET request that returns HTML
Server Action = a POST request on the current URL to side-effects like storing data