Server functions
One case per page
Each link is a single way to call a server function. Open one, read what it does, then look at the result.
Awaited loader
The loader waits for a GET server function. The result is already in the first HTML.
Streamed loader
The loader starts a slow GET and does not wait. The page appears first, then the result streams in.
Server component
A server function returns UI rendered on the server. The page displays that UI and has no client slot.
Streamed server component
The same server-rendered UI, returned as a promise so a fallback shows until it arrives.
Composite
The server renders the surrounding markup and leaves a slot. A client counter fills that slot.
Streamed composite
A composite returned as a promise. The fallback shows first, then the server markup and client slot appear.
Function calls a function
One server function awaits another on the server. The browser makes a single request.
Middleware
Middleware runs before the handler and passes a value through context. The handler returns that value.
Request header
The handler reads the user-agent on the server. That API is not available in the loader.
Validated input
The validator runs before the handler. A real name succeeds. An empty name throws and the handler never runs.
POST with useServerFn
A click handler calls a POST through useServerFn, then reloads the loader so the new note comes from the server.
Direct POST call
The same POST, called as a plain function from the click handler. It is still a request to the server.
FormData POST
The form sends FormData. The validator checks the type, reads the field, and rejects an empty value.
Thrown handler error
The handler throws. The click handler catches the error and shows its message.
redirect()
The loader awaits a server function that throws redirect() to the SSR page. This page does not render.
notFound()
The loader awaits a server function that throws notFound(). The route shows its not-found view.