Server Actions = mutation endpoints, declared inline
A Server Action is an async function that runs on the server but is callable from a Client Component. The framework wires it as a unique POST endpoint behind the scenes — you call it like a function, not like an API.
Two ways to declare
| Approach | How |
|---|---|
| File-level | 'use server' at the top of the file. Every exported function in that file is an action. |
| Inline | Inside a Server Component, define the function and put 'use server' at the top of its body. |
What they replace
For internal CRUD, you no longer need /api/…/route.ts + fetch() + JSON parsing on both sides. Server Actions are POST endpoints with built-in CSRF protection, encrypted action IDs, and automatic dead-code elimination of unused actions.
What they don't replace
Public APIs (third parties call them), webhooks, integrations, and anything that needs to expose a stable URL still belong in Route Handlers (covered in the next track).