tRPC ↗
An RPC framework for TypeScript that eliminates the REST/GraphQL layer entirely. Zod is tRPC's default input/output validator. Schemas you already know become end-to-end type-safe procedure contracts, with TypeScript inference flowing from server to client automatically.
API types silently drifting between server and client is a whole category of runtime bugs. tRPC uses Zod schemas as the single source of truth for what a procedure accepts and returns, making those bugs a compile-time error instead.
import { z } from 'zod';
import { router, publicProcedure } from './trpc';
export const userRouter = router({
getById: publicProcedure
.input(z.object({ id: z.number() }))
.output(z.object({ id: z.number(), name: z.string(), email: z.email() }))
.query(async ({ input }) => {
// input.id is typed as number
return db.users.findById(input.id);
}),
});const user = await trpc.user.getById.query({ id: 1 });
// user is typed as { id: number; name: string; email: string }
// TypeScript infers this directly from your server schema