At first glance I under the impression that Server Actions are just function written on server, to be executed on the server by some other server code or Server Component.
from NextJs docs
To my surprise, Server Action can also be called by the Client component (maked as 'use client').
This has left me all confused. How can an server function be called by a code running on browser? Seems like I am missing something. I couldn't find anything online about it.
So my question is:
How is Client component (browser code) able to call Server Actions (server code)? Would love to see some write up or a reference?
Client Components, despite the unfortunate naming, does not run only on the browser. Please correct me if I'm wrong.
As mentioned here,
I found these 2 videos that explain the concept well from the other answer recommended by StackOverflow AI: