Server Actions reference
Forms, the action identity, error codes, body limits and what does not work in a remote action.
Details behind Server Actions in islands.
Forms: no progressive enhancement
An island form is not submittable until the island hydrates.
<Form>from@next-federation/islandrenders a<fieldset disabled>on the server and enables it after hydration.- A plain
<form action={action}>, or aformActionoutside<Form>, warnsNF-035. - A
formActionbutton inside<Form>in the same component is not reported. One from another component cannot be checked, so the warning can be a false alarm. - Put a form that must work without JavaScript in the host.
Who the action runs as
Requests carry Authorization: Bearer <token>, never cookies. Without a token, getIdentity() is null.
- Private islands use the token of the user they rendered for.
- Public islands on a host with
getIdentityfetch a token for the current user on each action. The cached page stays static. - On
401 NF-014, the island fetches a new token and resends once. It never retriesNF-015,NF-016or a 5xx.
Errors
| Code | Meaning |
|---|---|
NF-033 | The action threw. The caller sees "Minified React error #441" and the remote logs the cause (details). |
NF-031 | The action id is unknown to the build, usually a page from one build calling another (details). |
NF-032 | The request is malformed, or the body is too large (413). |
NF-038 | The response is not a Server Action response, or the call timed out (details). |
NF-032is a400for a missing or malformedX-NF-Actionheader, an invalidislandquery parameter, a content type other thantext/plain;charset=UTF-8ormultipart/form-data, or an undecodable body. A413means the arguments exceed the limit, for example a file in<Form>(limits).NF-038is a 5xx, a content type other thantext/x-component, an empty body, or no answer withinactions.timeoutMs(when set). A 5xx means the remote is down, restarting or timed out, or a proxy or CDN failed.NF-031is also a plain function export in a'use server'file the bundler did not register.- The browser waits as long as the connection stays open. A proxy that cuts it surfaces as
NF-038. actions.timeoutMscovers the wait for the response, not a long streamed result.- Each call emits an
island:actionevent (ok,status,code,ms,retried) ononEventand thenf:islandDOM event. It never includes arguments, results or tokens.
What does not work
redirect(),notFound(),cookies(),headers()and othernext/*APIs. Return a value and let the island navigate.- Refreshing the island from the server. Only the calling island re-renders, from its own client state.
Body limits and NODE_ENV
| Limit | Default | Set with |
|---|---|---|
Build (413 with CORS) | 1 MiB | actions.maxBodyBytes in the Vite options |
nf-serve ceiling for /_nf/action | 8 MiB | maxActionBodyBytes of serveBuilds(). The CLI has no flag. |
Keep the build's limit below the ceiling so callers see the build's answer.
Run rsc/index.js with NODE_ENV=production (nf-serve does). A rejected promise nested in a return value is redacted only by the production Flight server. The development one sends the message and stack to the browser. The build warns when NODE_ENV is not production.
Closures and replicas
Actions defined inside Server Components capture arguments encrypted with a key that @vitejs/plugin-rsc generates per build. Replicas built separately need the same key. Set defineEncryptionKey to a runtime secret.