Skip to content

Server Actions

Spicy — senior dev territoryFrontend

ELI5 — The Vibe Check

Server Actions let you write a function in your React component that magically runs on the server when called. It's like passing a note to the server without setting up an API route. Form submissions just call a server function directly. The future is weird.

Real Talk

Server Actions are async functions in React that execute on the server, invoked directly from client components via form actions or event handlers. They enable mutations without explicit API routes, with automatic serialization and progressive enhancement support.

Show Me The Code

async function addTodo(formData: FormData) {
  'use server';
  await db.todos.create({ text: formData.get('text') });
  revalidatePath('/todos');
}

When You'll Hear This

"Server Actions killed half our API routes" / "Just slap 'use server' on it and the function runs server-side"

Made with passive-aggressive love by manoga.digital. Powered by Claude.