0
Challenge · 34Route Handlers, Streaming & PPR
When NOT a Server Action
Mutationsused in ~78% of apps
The fastest way to spot an engineer who has actually shipped Next.js is to ask: when do you reach for a Route Handler instead of a Server Action? Get it wrong and you build a public API on top of an obfuscated POST-only RPC that you can't cache, can't point a webhook at, and can't call from a mobile app — then spend a sprint fighting the framework instead of using the tool built for the job.
Core idea. A Server Action is a POST-only, uncacheable, internal RPC the framework wires to your own UI. The moment you need a different HTTP method, a cacheable response, a stable public URL, custom headers, streaming, or a caller that isn't your own React tree (a webhook, a mobile app, a third party), you've outgrown Server Actions — that's a Route Handler (`app/.../route.ts`). And you should never fetch data with a Server Action: read in Server Components or Route Handlers.
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