tRPC shares types between client and server automatically. No API schemas to maintain. TypeScript inference provides complete type safety. Client calls feel like local function calls.
Router Definition
Define procedures in routers with input validation. Queries fetch data, mutations modify state. Subscriptions enable real-time updates. Compose routers for organization.
- Define procedures with Zod input validation
- Use queries for read operations
- Implement mutations for writes
- Compose routers for logical grouping
- Access context for authentication and utilities
Client Integration
React Query powers tRPC's React client. Automatic caching and revalidation. Optimistic updates for responsiveness. Full type inference from server to client.