Sub topic 3
Server Functions and Server Actions: Terminology
This chapter assumes you know React components, props and hooks, and that you have a rough idea of how a browser sends a request to a server. It doesn't teach how to write Server Functions in detail. Later chapters do that. Its job is to fix the vocabulary, because documentation, blog posts and framework guides use "Server Function", "Server Action" and "Server Component" in ways that overlap and sometimes conflict.
By the end you should be able to do three things:
- Say which term applies to a given piece of code.
- Read older material that uses a different term.
- Avoid two common mix-ups: confusing Server Functions with Server Components, and thinking a Server Action is a separate feature.
Why the terminology matters
The same mechanism has been described under two names. Early material, including framework documentation written before React 19 shipped, called everything a "Server Action". Current React documentation uses "Server Function" for the mechanism and reserves "Server Action" for one particular way of using it.
If you don't know this, you may search for "Server Actions" and find advice that applies to all Server Functions, or you may assume that a function not used in a form is a different thing with different rules. Neither is true. The security rules, serialization rules and the "use server" directive apply to the function, regardless of where it is called from.
The definitions
These are the terms as current React documentation uses them.
- Server Function: an async function that runs on the server and that client code can call. You mark it with the
"use server"directive. This is the base concept. - Server Action: a Server Function that is used as an Action. An Action is React's name for a function that React runs inside a transition, typically passed to a
<form>'sactionprop or to a<button>'sformActionprop. A Server Action is therefore a Server Function in a particular role. - Server Component: a component that renders on the server. It has nothing to do with
"use server". This is the term most often confused with the other two. - Action (without "Server"): a function React runs in a transition, whether it runs on the client or the server. A client-only function passed to
<form action={...}>is an Action but not a Server Action.
The relationship is one of containment, shown below.
One function, two roles
The following file defines a single Server Function. Nothing in the file says "action". The role comes from how it is used later.
// app/actions.js
'use server';
import { db } from './db';
export async function createNote(formData) {
const title = formData.get('title');
await db.notes.insert({ title });
}The file-level "use server" directive marks every exported async function in the file as a Server Function. The db module is a placeholder for your data layer.
Here the same kind of function is passed to a form's action prop. In that position it is a Server Action.
// app/page.js (a Server Component)
import { db } from './db';
export default function Page() {
async function createNote(formData) {
'use server';
await db.notes.insert({ title: formData.get('title') });
}
return (
<form action={createNote}>
<input name="title" required />
<button type="submit">Add note</button>
</form>
);
}createNote is defined inside a Server Component, and the function-level directive marks that single function. React calls it with the submitted FormData when the form submits. That is the Server Action role.
Now a function used a different way. A Client Component calls deleteNote from an event handler, wrapped in startTransition.
// app/DeleteButton.js
'use client';
import { useTransition } from 'react';
import { deleteNote } from './actions';
export function DeleteButton({ noteId }) {
const [isPending, startTransition] = useTransition();
return (
<button
disabled={isPending}
onClick={() => {
startTransition(async () => {
await deleteNote(noteId);
});
}}
>
{isPending ? 'Deleting…' : 'Delete'}
</button>
);
}deleteNote is a Server Function. Because it runs inside startTransition, React treats the call as an Action, so by React's definition it is also being used as a Server Action. If you called deleteNote(noteId) straight from an onClick handler with no transition, it would still be a Server Function and a network request, but React would not track its pending state for you.
Comparison table
| Term | What it is | Where it runs | Marked by |
|---|---|---|---|
| Server Component | A component that renders on the server | Server | Nothing. Components in a React Server Components setup are server components by default. |
| Client Component | A component that renders in the browser (and can be pre-rendered on the server) | Browser | `"use client"` at the top of a file |
| Server Function | An async function the client can call | Server | `"use server"` at file level or function level |
| Server Action | A Server Function used as an Action (form `action`, `formAction`, or inside a transition) | Server | Same as Server Function. The role comes from usage. |
| Action | A function React runs in a transition | Client or server | Passed to an `action` prop or run via `startTransition` |
The most common mix-up: `"use server"` is not for Server Components
Many developers assume "use server" marks a component as a Server Component. It doesn't. A Server Component needs no directive. The "use server" directive marks functions that the client can call. The matching directive for the other side of the boundary is "use client", which marks the entry point of code that runs in the browser.
A short way to remember it:
"use client"says: "this module and what it imports run on the client.""use server"says: "these async functions run on the server and may be called from the client."- No directive in a Server Components environment means: "this is a server module."
Reading older and framework-specific material
You will meet the terms in several forms. The table below translates them.
| What you read | What it usually means today |
|---|---|
| "Server Actions" used for any function marked `"use server"` | Server Functions |
| "Server Actions" used for a function passed to `<form action>` | Server Actions, in the current strict sense |
| "Server Functions" in a framework guide | The same thing as in React's documentation, though a framework may still use "Server Actions" as its main label |
| "Actions" with no "Server" | React's Actions concept, which may be fully client-side |
Frameworks that integrate Server Functions, such as Next.js, may keep their own wording. When a framework guide and the React documentation disagree on a name, check what the code does: is there a "use server" directive, and is the function used as an Action? Those two questions resolve almost every ambiguity.
Why the distinction has practical consequences
The two names point at different concerns.
Server Function concerns apply to every function with the directive:
- It is reachable by a request from the client, so it needs input validation, authentication and authorization.
- Its arguments and return values must be serializable.
- It must be async.
Server Action concerns apply only when the function is used as an Action:
- It receives
FormDatawhen used as a form action, or the previous state andFormDatawhen wrapped withuseActionState. - Pending state can be tracked with
useFormStatusoruseActionState. - Forms can work before JavaScript loads in a framework that supports it, which is called progressive enhancement.
This is why one function may need FormData handling in one place and plain arguments in another. Here is the useActionState shape, where the function takes the previous state first:
// app/actions.js
'use server';
import { db } from './db';
export async function createNote(prevState, formData) {
const title = String(formData.get('title') ?? '').trim();
if (title.length === 0) {
return { error: 'Title is required.' };
}
await db.notes.insert({ title });
return { error: null };
}The signature differs from the earlier createNote(formData). That is a Server Action concern: how React calls the function in the Action role determines which arguments arrive.
Common errors that come from the terminology
- Searching for the wrong term. If a search for "Server Functions" returns little, try "Server Actions". Older articles use that name for the whole mechanism.
- Believing a function called outside a form is not a Server Function. It is. Any function marked with
"use server"is one, whatever calls it. - Believing a Server Action is exempt from security review because "it's only a form handler". A client can call the endpoint with any arguments, not only the ones your form sends.
- Using
"use server"to mean "server-only code". The directive makes a function callable from the client. It is not a way to hide a module. A module that should never reach the browser needs different protection, since marking it"use server"adds a public entry point. - Mixing up the two directives when they sit in the same project. A file can't be both a client module and a server-function module. Keep
"use client"components in one file and the Server Functions they import in another, as theDeleteButtonexample does.
Summary of the working vocabulary
Use these in your own code reviews and documentation:
- Say "Server Function" when you mean the function and its rules.
- Say "Server Action" when you mean that function in an Action role, such as a form's
action. - Say "Server Component" only for components, and never connect it to
"use server". - Say "Action" for the React concept, which may or may not involve the server.
Exercise
A teammate says "'use server' at the top of Dashboard.js will make the dashboard a Server Component." Another file has export async function archiveNote(id) under a file-level 'use server', and a Client Component calls it inside startTransition. Correct the teammate, and name archiveNote using the terms from this chapter.
Show answer
The teammate is wrong. A Server Component needs no directive in a server-components setup, and a file-level 'use server' would turn the exports of Dashboard.js into Server Functions, which is not the intent. The directive marks functions the client can call. archiveNote is a Server Function because it is an async function marked with 'use server'. Since it is called inside startTransition, it is used as an Action, so it is also acting as a Server Action. It still needs input validation and authorization, because it is a public endpoint.
Exercise
A form passes a function to <form action={...}>. The function is defined with 'use server' inside a Server Component. A second button calls the same function directly from a plain onClick, with no transition. Which uses are Server Actions, and which rules apply to both?
Show answer
The form use is a Server Action, because the function is passed to a form's action prop. The direct onClick call, with no transition, is a Server Function call that is not used as an Action, so React does not track its pending state. In both uses the function is a Server Function, so serialization rules, validation, authentication and authorization apply to both.