Do multiple server actions resolve to one lambda call or is it multiple?
A few questions on server actions in Nextjs
1) Can I have a server action call another server action? I don't see why not.
2) If so, does that result in two lambda functions being invoked or does it just treat it as a function calling another function and in terms of lambdas, it just becomes one lambda instance? Which I think so...
3) If it's just one lambda call, is there a difference between writing "use server" in the second function that the first server function calls?
It's just symantics to ensure it's running on the server right? Doesn't really make that much of a difference and it's just safer to put it I guess but it doesn't neccessite that it becomes two lambda calls right? I also note that this is slightly different than the
server only
directive which protects env variables from being exposed on the client by accident.
That is, writing use server
is more for the developer to explicitly see that it's running on a server, and multiple server actions with use server
can call each other and it's still one lambda call right?0 Replies