Mutations, Form handling, and RPC-style calls.
Handle form submissions and mutations without creating API endpoints.
'use server' at the top of an async function.action prop of <form> or invoke from event handlers.// actions.ts
'use server';
export async function createPost(formData: FormData) {
const title = formData.get('title');
await db.post.create({ title });
revalidatePath('/posts'); // Refresh UI
}
<form action={createPost}> (Progressive enhancements work without JS).onClick={() => createPost(data)}.useFormStatus hook (must be inside a component rendered within the form).FormData or arguments on the server.{ success: boolean, error?: string } to handle feedback on Client.auth() (e.g., NextAuth) session inside every Server Action.actions.ts).