Zod recipes
22 tested Zod integration recipes with @anthropic-ai/sdk, papaparse, Drizzle ORM, drizzle-zod. Exact pinned versions and a last-passed receipt, last run 2026-10-15.
Anthropic TypeScript SDK tool use loop, tested with a mocked fetch
Run a Claude tool_use loop with the official Anthropic SDK and Zod-validated tool inputs, tested offline with an injected fetch.
CSV import with PapaParse + Zod row validation
Parse CSV uploads with PapaParse (headers, BOM, quoted fields), validate each row with Zod and report row-numbered errors instead of failing the whole file.
Drizzle ORM + drizzle-zod validated inserts on SQLite
Generate Zod insert and select schemas from Drizzle tables with drizzle-zod, refine them, and validate input before inserting into SQLite.
Express 5 + Zod 4 request validation
Validate JSON bodies in Express 5 with a reusable Zod middleware that returns 400 with field errors.
Fastify 5 + Zod 4 type provider for typed routes
Use fastify-type-provider-zod so Zod 4 schemas validate requests, serialize responses and type handlers in Fastify 5.
Hono + @hono/zod-openapi typed routes with generated OpenAPI docs
Define Hono routes with createRoute and Zod schemas so requests are validated, handlers are typed and an OpenAPI 3.1 document is generated at /doc.
Hono + Drizzle ORM + SQLite REST API (Vitest)
CRUD REST API in Hono backed by Drizzle ORM on better-sqlite3, with Zod validation, tested with Vitest and app.request().
Hono + hono/jwt bearer auth with Zod login
Issue HS256 JWTs from a Zod-validated login route in Hono and guard routes with the built-in jwt middleware.
Hono + Zod validator API
Hono routes with @hono/zod-validator for JSON and query validation, tested with app.request().
LangChain.js prompt + model + parser chain tested with a fake chat model
Compose a ChatPromptTemplate, chat model and output parser with LCEL in @langchain/core, tested offline with FakeListChatModel.
LangChain.js tools with Zod schemas and a manual tool-calling loop
Define LangChain.js tools with tool() and Zod schemas, run model tool_calls through them, and feed ToolMessages back, tested with a scripted fake chat model.
Next.js 16 App Router route handler + Zod validation
Validate JSON bodies and search params in a Next.js App Router route handler with Zod, returning typed 400s; tested by calling the handler with NextRequest.
Next.js 16 server actions + Zod with useActionState-shaped results
A 'use server' form action that validates FormData with Zod and returns field errors in the shape useActionState expects, tested by calling the action directly.
OpenAI Node SDK tool calling + Zod, tested with a mocked fetch
Run an OpenAI chat tool-calling loop with Zod-validated tool arguments, tested offline by injecting a fake fetch into the official SDK.
React Hook Form + Zod 4 resolver schemas (no DOM)
Share one Zod schema between React Hook Form (via @hookform/resolvers) and the server, with cross-field refinements, tested by calling the resolver directly.
React Router 8 data loaders and actions tested with createStaticHandler
Route loaders and actions with redirects, validation errors and 404 responses in React Router's data APIs, tested offline with createStaticHandler and plain Requests.
SvelteKit form actions with fail() and Zod, unit-tested (Vitest)
SvelteKit +page.server.ts form actions that validate with Zod, return fail(400) with field errors, and redirect on success, tested by calling the actions with a fake RequestEvent.
tRPC 11 + Zod router with server-side caller
A typed tRPC router with Zod inputs, an auth middleware, and tests through createCaller.
tRPC 11 client + server over fetch with superjson (Vitest)
End-to-end typed tRPC 11: fetch adapter server, createTRPCClient with httpBatchLink and superjson transformer for Dates and Maps, tested in-process with Vitest.
tRPC 11 context, auth middleware and createCaller tests
tRPC 11 router with a request context, a protectedProcedure built from middleware, Zod inputs and TRPCError codes, tested with createCaller (no HTTP).
Typed fetch API client tested with MSW + Zod
A typed fetch client that parses responses with Zod, tested offline by intercepting requests with MSW's Node server.
Zod 4 + dotenv typed environment config
Load .env files with dotenv and validate process.env with Zod 4 at startup: coercion, defaults, enums, URLs and readable errors.
Used together with Zod
@anthropic-ai/sdkpapaparseDrizzle ORMdrizzle-zodbetter-sqlite3ExpressFastifyfastify-type-provider-zodHono@hono/zod-openapi@hono/zod-validatorvitest@langchain/corenextreactopenaireact-hook-form@hookform/resolversreact-router@sveltejs/kitsveltetRPC@trpc/server@trpc/clientsuperjsonMSWdotenv