/zod-4:integrating-zod-frameworksfrom zod-4
Integrate Zod v4 with React Hook Form, Next.js, Express, tRPC, and other frameworks for type-safe validation
Ships in zod-4. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Comprehensive guide to integrating Zod v4 validation with popular frameworks including React Hook Form, Next.js Server Actions, Express APIs, tRPC, and more.
Zod integrates seamlessly with:
Frontend Frameworks:
zodResolverBackend Frameworks:
.input()Database/ORM:
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
const formSchema = z.object({
email: z.email().trim().toLowerCase(),
password: z.string().min(8)
});
type FormData = z.infer<typeof formSchema>;
function Form() {
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
resolver: zodResolver(formSchema)
});
return (
<form onSubmit={handleSubmit(data => console.log(data))}>
<input {...register('email')} />
{errors.email && <span>{errors.email.message}</span>}
<button type="submit">Submit</button>
</form>
);
}
'use server';
const schema = z.object({
email: z.email().trim().toLowerCase()
});
export async function createUser(formData: FormData) {
const result = schema.safeParse({
email: formData.get('email')
});
if (!result.success) {
return { errors: result.error.flatten().fieldErrors };
}
return { data: await db.create(result.data) };
}
import express from 'express';
function validate<T extends z.ZodTypeAny>(schema: T) {
return (req, res, next) => {
const result = schema.safeParse(req.body);
if (!result.success) {
return res.status(400).json({ error: result.error.flatten() });
}
req.body = result.data;
next();
};
}
const userSchema = z.object({ email: z.email() });
app.post('/users', validate(userSchema), async (req, res) => {
const user = await createUser(req.body);
res.json(user);
});
import { initTRPC } from '@trpc/server';
const t = initTRPC.create();
const createUserInput = z.object({
email: z.email().trim().toLowerCase(),
name: z.string().trim().min(1)
});
export const appRouter = t.router({
createUser: t.procedure
.input(createUserInput)
.mutation(async ({ input }) => {
return await db.users.create({ data: input });
})
});
const schema = z.object({...}); // ✅ Reusable
function handler() {
const schema = z.object({...}); // ❌ Recreated
}
type FormData = z.infer<typeof formSchema>; // ✅
interface FormData { ... } // ❌ Duplicates schema
z.email().trim().toLowerCase() // ✅ Normalize
z.email() // ❌ No normalization
const result = schema.safeParse(userInput); // ✅
try { schema.parse(userInput) } // ❌
z.email({ error: "Invalid email" }) // ✅
z.email() // ❌ Generic error
export async function createUser(data: unknown) {
const validated = schema.parse(data); // ✅
}
export async function createUser(data: User) {
await db.create(data); // ❌ No validation
}
zodResolver for automatic integrationvalueAsNumber for number inputssafeParsez.stringbool() for checkbox values.input() with Zod schemasCross-Plugin References:
React 19 Integration:
Next.js 16 Integration:
Prisma 6 Integration:
What SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/customizing-errorsHandle Zod validation errors with unified error API, custom messages, error formatting, and user-friendly display/migrating-v3-to-v4Complete migration guide from Zod v3 to v4 covering all breaking changes and upgrade patterns/optimizing-performanceOptimize Zod validation performance with safeParse, bulk array validation, schema reuse, and passthrough patternsOther plugins' skills for the same job
/reviewing-patternsReview Zod schemas for correctness, performance, and v4 best practicesnpx claudepluginhub djankies/claude-configs --plugin zod-4