Websites10 min read

Server Actions Next.js 15: production patterns 2026

Mohamed Bah·Fondateur, Kolonell
May 26, 2026
Share:
Server Actions Next.js 15: production patterns 2026

Server Actions Next.js 15: production patterns 2026

Websites

Next.js 14 stabilized Server Actions. Next.js 15 (released 2024) refined them. In 2026, they replace ~70% of API routes for form-driven mutations. But production patterns = poorly documented. Here are the 8 essential patterns.

TL;DR

- Server Actions = server functions callable directly from React components.

- Pros: type-safe, no API endpoint, progressive enhancement.

- Patterns: Zod validation, optimistic UI, revalidation, error handling.

Basic Server Action

`tsx

'use server';

import { revalidatePath } from 'next/cache';

import { z } from 'zod';

import { prisma } from '@/lib/prisma';

const CreatePostSchema = z.object({

title: z.string().min(3).max(200),

content: z.string().min(10),

});

export async function createPost(formData: FormData) {

const parsed = CreatePostSchema.safeParse({

title: formData.get('title'),

content: formData.get('content'),

});

if (!parsed.success) {

return { error: parsed.error.flatten() };

}

const post = await prisma.post.create({ data: parsed.data });

revalidatePath('/posts');

return { success: true, post };

}

`

`tsx

import { createPost } from '@/app/actions/posts';

export function CreatePostForm() {

return (