Next.js 16 · Data and server code
Create a server action
A function marked "use server" runs on the server and can be called from forms.
"use server";
export async function createPost(formData: FormData) {
const title = formData.get("title");
// save the post
}
Official Next.js 16 documentation