Server Actions
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"
Related Terms
App Router
App Router is Next.js's new routing system that uses the app/ directory and embraces React Server Components.
React Server Components
React Server Components run on the server and send zero JavaScript to the browser.
Zod
Zod is your runtime bouncer for TypeScript. TypeScript checks types at build time, but Zod checks them when actual data arrives. API response looks weird?