Server action with form handling and revalidatePath. Mutations from the client.
'use server';
import { revalidatePath } from 'next/cache';
export async function submitForm(formData: FormData) {
const name = formData.get('name') as string;
// ... validate and save
revalidatePath('/dashboard');
return { ok: true };
}
// In client component: <form action={submitForm}> or startTransition(() => submitForm(data))
Mark with 'use server'. Can be passed to form action or called from client (with transition). Runs on server.
Call revalidatePath or revalidateTag after mutation so the UI reflects new data.
revalidatePath('/posts');