How does React Server Actions work in React 19?

Answer

React Server Actions (stable in React 19, via Next.js App Router) are async functions that run on the server and can be called from client components — without needing to write a separate API endpoint. Mark a function with "use server" directive to make it a server action: async function createUser(formData) { "use server"; await db.user.create({ data: { name: formData.get("name") } }); revalidatePath("/users"); }. Invoking from client: pass to a form's action prop: <form action={createUser}><input name="name" /><button>Create</button></form>. The form submission calls the server function without page reload or manual fetch. With useActionState (React 19): const [state, action, isPending] = useActionState(createUser, null); — tracks pending state and the last result. Benefits: no API route boilerplate; progressive enhancement (works without JavaScript for form submissions); mutations are colocated with components; automatic CSRF protection in frameworks; direct database/service access. Security: never trust client-provided data — validate and authorize in the server action body.