Next.js Discord

Discord Forum

Call Server Action from server side

Answered
Lesser White-fronted Goose posted this in #help-forum
Open in Discord
Lesser White-fronted GooseOP
Hi!

Got curious on how server actions work in some scenarios:

1. What would happens if you call a server action from a server component? Would it stil get a network call? Or would next recognize that this is a server action call from the server and just call the function directly?
2. What happens if you call a server action from another server action? Same a s above, network call or next optimize to a function call
Answered by B33fb0n3
1. it would just execute the function itself. There won't be an additional network call (for a route handler this is different)
2. Same as 1st
View full answer

6 Replies

Answer
Lesser White-fronted GooseOP
Thanks for the quick reply 🙏
Okay nice! Makes sense!
happy to help
Lesser White-fronted GooseOP
Do you have a link to docs or source for this btw? 🙂
@Lesser White-fronted Goose Do you have a link to docs or source for this btw? 🙂
Unfortunately I don't have it. When you search inside the #discussions you can find a discussion about this topic. We tested it. I was included inside the discussion (so you can find it)