0
Challenge · 25Mutations & Auth
Server Actions = public POST endpoints
Mutationsused in ~92% of apps
Every `"use server"` function you write is a publicly reachable HTTP endpoint. If you treat it like a trusted private method, you have just shipped an unauthenticated mutation API — and an attacker doesn't need your UI, your form, or even a browser to call it.
Core idea. A Server Action compiles to a POST endpoint identified by an opaque action ID. Next.js wires the form/button to it, but nothing stops anyone from POSTing that ID with any payload they invent. The ID is obfuscation, not authorization. Every action must do the full server-side dance itself: authenticate → authorize → validate (Zod) → mutate → revalidate.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
CRUD ↔ HTTP verb
POSTCreateGETReadPATCHUpdateDELETEDelete
local list (React state)2 items
#1Ship the feed
#2Review PRs
network — request / response
Add, edit, or delete an item. Watch the HTTP verb fire, then the local list update after the response.
Each mutation waits for the server's response, then updates the local list immutably (map / filter / spread) — no full refetch. Showing the change before the response is optimistic UI (#71).
↑ play a little first, then dig in