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

More data and server code commands

All data and server code commands · Next.js 16 cheatsheet

Was this page helpful?