The tRPC Architecture
How tRPC eliminates API schema duplication.
The End-to-End Problem
In a typical web app, the server defines an API and the client calls it. Keeping their types in sync is hard: change a field on the server and the client silently breaks at runtime. tRPC solves this by sharing types directly, with no code generation.
// Server: returns { id: number; name: string }
// Client: must know that shape exactly
// Without sync: runtime errors when they driftWhat tRPC Is
tRPC is a library for building fully typed APIs in TypeScript. The server defines procedures; the client calls them as if they were local functions, with complete autocomplete and type checking inferred from the server code.
// Client call looks like a local function:
// const user = await client.user.byId.query(1);
// user is typed automatically from the serverAll lessons in this course
- The tRPC Architecture
- Defining Routers and Procedures
- Client-Server Type Inference
- Middleware and Context