Server Action (Next.js)
GlossaryA Next.js App Router function marked `'use server'` that runs on the server and can be called from a form.
Definition
A Server Action in Next.js App Router is an async function marked with the `'use server'` directive that runs on the server — it can be passed directly to a `<form action={}>` prop or called from a React event handler. It enables progressive enhancement: the form works with JavaScript disabled (full-page POST) and enhances to an in-place update when JS is on. For FormLoom, the Server Action reads FormData and POSTs it to the FormLoom endpoint from the server side.
Why it matters for form backends
Server Actions are the canonical way to handle forms in Next.js 15 with App Router. FormLoom slots in behind the action to handle storage, spam, and email.
Example
"use server";
export async function contactAction(_prev: unknown, fd: FormData) {
const res = await fetch("https://api.formloom.ai/submit/YOUR_ACCESS_KEY", {
method: "POST",
headers: { Accept: "application/json" },
body: fd,
});
return res.json();
}FAQ
Related terms
Ready to put this into practice?
Add a form to your site in minutes — free access key, copy-paste snippet.