Capítulo 111 de 116
Server Functions are functions marked 'use server' that a Client Component can call as if they were local — React handles serializing the call across the network, running it on the server, and returning the result, most commonly used as a form's action (Ch 97) or an event handler triggering server-side work.
'use server': placed at the top of a function (or a module, marking every export in it) to designate it as callable from the client but always executing on the server — the function body genuinely only runs server-side, never shipped to the browser.<form action={serverFunction}> (Ch 97): submitting the form calls the Server Function directly with FormData, with progressive enhancement (the browser can submit via a real HTTP request even before JS loads) as a direct consequence.// actions.js
'use server';
export async function createPost(formData) {
await db.posts.create({ title: formData.get('title') });
}
// Client Component
<form action={createPost}>
<input name="title" />
</form>
action, with the function's actual database logic never shipping to the browser.'use server' marks a function as a client-callable, server-only network boundary — not just "runs on the server" but "is invokable from client code."<form>): the most common calling pattern for Server Functions.'use server'): the directive reference this chapter's mechanism is built on.