trpc
Use when building type-safe APIs with tRPC — procedure definitions, routers, middleware, or client integration. Also use when connecting Next.js/React frontends to tRPC backends or debugging type inference issues.
| Model | Source |
|---|---|
| sonnet | pack: backend |
Full Reference
┏━ 🔧 trpc ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when building type-safe APIs with tRPC — p… ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
End-to-end typesafe APIs for TypeScript monorepos. No schemas, no codegen — the router IS the contract. Pairs with Zod for input validation and TanStack Query for client-side data fetching.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Version | v11 (released March 21, 2025) |
| Node.js min | 18+ |
| TypeScript min | 5.7.2+ |
| Core install | npm i @trpc/server @trpc/client @trpc/react-query @tanstack/react-query zod |
| Transformer | superjson — goes in httpBatchLink({ transformer: superjson }), not initTRPC |
| Renamed in v11 | createTRPCProxyClient → createTRPCClient, isLoading → isPending, rawInput → getRawInput() |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Set up tRPC with Next.js App Router or standalone | reference/setup.md |
| Define queries, mutations, and nested routers | reference/procedures.md |
| Add auth, logging, and rate limiting middleware | reference/middleware.md |
| Integrate the client with React hooks or vanilla TS | reference/client.md |
| Handle TRPCError codes and format error responses | reference/error-handling.md |
| Set up SSE subscriptions and WebSockets | reference/subscriptions.md |
| Unit test procedures with createCaller | reference/testing.md |
| Decide if tRPC is the right choice | reference/when-not-to-use.md |
Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.