→ chapters/04-server-actions

Card · Server Actions

Mutation entry: validate → authorize → entity → revalidate.

Sequence

  1. Read session/permissions.
  2. Validate input; authorize.
  3. Call entity action; revalidatePath.

Skeleton

"use server";
export async function createProjectAction(formData) {
const session = await getSession();
if (!session) throw new Error("Unauthorized");
await createProject(formData, session.user.id);
revalidatePath("/projects");
}

Study Card · Chapter 04-server-actions