What is Server Actions?
Next.js feature letting you write server-side mutation functions that you call directly from form components and event handlers, without writing API routes.
Server Actions are async functions marked with `"use server"` that run on the server but can be invoked directly from React components — including from `<form action={myAction}>` and `onClick` handlers in client components. They eliminate the boilerplate of writing a separate API route + client fetch for every mutation. Under the hood, Next.js automatically generates a POST endpoint per action, serializes the arguments, and runs the function server-side with full access to your database, environment variables, and authentication context. Server Actions integrate with React's `useActionState` hook for optimistic UI and pending states, and with `revalidatePath`/`revalidateTag` for cache invalidation after mutations. Tradeoff: actions are tied to your Next.js deployment — they can't be called from non-Next clients. For public API contracts, use route handlers (`route.ts`) instead.