Skip to content

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.

ModelSource
sonnetpack: 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.

ItemValue
Versionv11 (released March 21, 2025)
Node.js min18+
TypeScript min5.7.2+
Core installnpm i @trpc/server @trpc/client @trpc/react-query @tanstack/react-query zod
Transformersuperjson — goes in httpBatchLink({ transformer: superjson }), not initTRPC
Renamed in v11createTRPCProxyClientcreateTRPCClient, isLoadingisPending, rawInputgetRawInput()
I want to…File
Set up tRPC with Next.js App Router or standalonereference/setup.md
Define queries, mutations, and nested routersreference/procedures.md
Add auth, logging, and rate limiting middlewarereference/middleware.md
Integrate the client with React hooks or vanilla TSreference/client.md
Handle TRPCError codes and format error responsesreference/error-handling.md
Set up SSE subscriptions and WebSocketsreference/subscriptions.md
Unit test procedures with createCallerreference/testing.md
Decide if tRPC is the right choicereference/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.