Server actions in server components

I have been under the assumption that calling a function marked with use server on the server is just treated as a regular server function. But I then stumbled upon a random vid where the guy mentions that calling a server action from the server means the server will be fetching from what's effectively an API route the same way client components do. Couldn't find explicit evidence for this claim though. If that's true then it's quite ridiculous that use server is not just ignored by server components, unless there's some use case for this? Hoping someone can refute this claim so I can keep using the same function for actions and server functions in peace.
4 Replies
Salumsu
Salumsu3mo ago
up
Hidden
Hidden3mo ago
Linking the video in question here would help a lot.
Y7YA
Y7YAOP3mo ago
I lost the link unfortunately, but it wasn't an authoritative figure and the guy himself said he wasn't sure.
lanc3
lanc33mo ago
this doesn't seem true based on a quick investigation of a next.js build. This is what next.js builds with i being an module that exports a server action called action and it's relatively clear that next.js simply calls it like any other regular function. Furthermore, when passing a server action to a client component like in the latter image, it actually appears to be a proxy, where n.j seems to register that it is a server action rather than simply import the function like on the server
No description
No description
No description
Want results from more Discord servers?
Add your server