Teaches Server Actions in React 19 for form handling and data mutations. Use when implementing forms, mutations, or server-side logic. Server Actions are async functions marked with 'use server'.
Implements React 19 Server Actions for form handling and data mutations. Use when creating forms that need server-side processing, validation, and authentication. Triggers on form submissions, async mutations, and secure data operations.
/plugin marketplace add djankies/claude-configs/plugin install react-19@claude-configsThis skill is limited to using the following tools:
Server Actions are async functions executed on the server, callable from Client Components.
Defining Server Actions:
'use server';
export async function createUser(formData) {
const name = formData.get('name');
const email = formData.get('email');
const user = await db.users.create({ name, email });
return { success: true, userId: user.id };
}
Using in Forms:
'use client';
import { createUser } from './actions';
function SignupForm() {
return (
<form action={createUser}>
<input name="name" required />
<input name="email" type="email" required />
<button type="submit">Sign Up</button>
</form>
);
}
MUST validate all inputs:
'use server';
import { z } from 'zod';
const schema = z.object({
name: z.string().min(2).max(50),
email: z.string().email(),
});
export async function createUser(formData) {
const result = schema.safeParse({
name: formData.get('name'),
email: formData.get('email'),
});
if (!result.success) {
return { error: result.error.flatten().fieldErrors };
}
const user = await db.users.create(result.data);
return { success: true, userId: user.id };
}
MUST check authentication:
'use server';
export async function deletePost(postId) {
const session = await getSession();
if (!session?.user) {
throw new Error('Unauthorized');
}
const post = await db.posts.findUnique({ where: { id: postId } });
if (post.authorId !== session.user.id) {
throw new Error('Forbidden');
}
await db.posts.delete({ where: { id: postId } });
return { success: true };
}
Server Actions work before JavaScript loads:
'use client';
import { useActionState } from 'react';
import { submitForm } from './actions';
function Form() {
const [state, formAction] = useActionState(
submitForm,
null,
'/api/submit'
);
return <form action={formAction}>...</form>;
}
For comprehensive Server Actions documentation, see: research/react-19-comprehensive.md lines 644-733.
Zod v4 Error Handling:
Prisma 6 Integration: