is it normal that server actions post to the page url instead of an api route Mutations
Coming from express, so I expected to see POST /api/something. Devtools shows POST /dashboard with a Next-Action: 60a1c8... header, and the response body is a stream of numbered lines rather than JSON. Nothing in my code mentions /dashboard as an endpoint. Is that expected or did I wire something up wrong?
@iron_camber · 3w ago · 2 replies
Expected. Actions are addressed by an id, not by a URL — the header is the id, and the POST goes to whatever route you are currently on so the server can re-render that route and stream the updated UI back in the same response as your return value. That is why you get one round trip for "mutate and refresh" instead of two.
The numbered lines are the RSC payload format. It is not meant to be read by humans and it is not a stable API.
Reply
Report
@newborn_noob · 3w ago
So the revalidated UI and the return value come back together. That explains why my
router.refresh()after every action was doing nothing useful except a second fetch.Reply
Report