Why Should You Use TypeScript?

1/9/2026
89 views
1 min read
Slide 1
Slide 2
Slide 3

Swipe or use arrows to see more photos

Next.js 15 Server Actions Tutorial

Server Actions are a powerful feature in Next.js that allow you to run server-side logic directly from React components without creating separate API routes.

What Is a Server Action?

A Server Action is an asynchronous function that runs on the server but can be called from Client Components like a regular JavaScript function.

Why Use Server Actions?

  • No need to manually create API routes
  • Cleaner and more maintainable code
  • Secure execution on the server
  • Simple form handling

Basic Example

To define a Server Action, add the "use server" directive.

"use server";

export async function createTodo(formData: FormData) {
  const title = formData.get("title");
  console.log("Todo created:", title);
}

Server Actions simplify data mutations and make modern Next.js applications easier to maintain.