What Is tRPC v11 and Why Does Type Safety Matter?
tRPC (TypeScript Remote Procedure Call) is a framework for building end-to-end type-safe APIs in TypeScript applications — without code generation, schema files, or REST/GraphQL conventions. When combined with Next.js 15's React Server Components and App Router architecture, tRPC v11 provides a development experience where the TypeScript types from your server-side procedure definitions are automatically available in your client-side React components, with TypeScript checking that input and output shapes are correct at compile time. This eliminates an entire class of runtime errors — type mismatches between frontend expectations and backend responses — that traditionally required manual coordination between frontend and backend developers, or complex GraphQL codegen pipelines to manage. In 2026, tRPC + Next.js is the dominant choice for TypeScript-first teams building full-stack applications that don't require a public-facing API.
tRPC v11: What's New
tRPC v11 represents a significant architectural evolution from v10, with major changes targeting Next.js App Router compatibility, React Server Component support, and improved streaming for long-running procedures.
React Server Component (RSC) support is the headline v11 feature. In Next.js 15 with App Router, RSCs run on the server and can call tRPC procedures directly using the new createCallerFactory API — with full type safety but no HTTP round-trip overhead. Server Components calling tRPC procedures behave like direct function calls internally while maintaining the same tRPC API structure used by client components, enabling a unified API layer across both RSC and client-side usage.
Streaming support via async generators allows tRPC procedures to stream data progressively to the client, compatible with React's Suspense boundaries. Long-running AI inference calls, database streaming queries, and real-time data feeds can all be modelled as streaming tRPC procedures with full TypeScript typing on the streamed output type.
Improved middleware system in v11 provides stronger typing through middleware chains. Context augmentation — adding authentication information, database client instances, or request metadata to the procedure context — now provides precise TypeScript types at each middleware stage, making it easier to write safe middleware that correctly threads through required context without runtime type assertions.
Enhanced error handling introduces structured error codes that are type-safe on both server and client, enabling precise error discrimination in client-side error handling without string matching on error messages. This pattern is particularly valuable for form validation flows where different error types require different UI responses.
Full-Stack API Approaches: TypeScript Comparison
| Approach | Type Safety | Code Gen Required | Bundle Impact | Public API Support | Best For |
|---|---|---|---|---|---|
| tRPC v11 | End-to-end, compile-time | None | ~12KB client | No | Full-stack TypeScript apps |
| GraphQL + Codegen | End-to-end, via codegen | Yes | ~30–50KB | Yes | Multi-client, public APIs |
| REST + Zod + OpenAPI | Runtime validation only | Optional | ~8KB (Zod) | Yes | Public APIs, non-TS clients |
| Server Actions (Next.js) | Partial (no client schema) | None | Zero | No | Simple form mutations |
| Hono + Zod | Runtime + partial compile | Optional (Zod openapi) | ~4KB | Yes | Edge-deployed APIs |
Setting Up tRPC v11 with Next.js 15
A production-grade tRPC v11 + Next.js 15 setup requires configuration across several files. The following guide covers the recommended architecture for a full-stack App Router application.
Installation and dependencies begin with npm install @trpc/server@11 @trpc/client@11 @trpc/react-query@11 @trpc/next@11 @tanstack/react-query zod. The React Query integration is required for client-side data fetching; tRPC v11 uses React Query v5 which requires the updated query key and mutation patterns introduced in that version.
Server-side setup creates the tRPC instance with context. In src/server/trpc.ts, initialise tRPC with initTRPC.context<Context>().create() where Context is the type of your request context (user session, database client, etc.). Create base procedure types — publicProcedure and protectedProcedure — with appropriate middleware applying authentication and context setup. Define your router with procedures using router({ procedureName: publicProcedure.input(zodSchema).query(handler) }).
Next.js Route Handler integration exposes the tRPC router via a catch-all API route at app/api/trpc/[trpc]/route.ts using fetchRequestHandler from @trpc/server/adapters/fetch. This adapter is compatible with Next.js 15's edge runtime and provides the HTTP layer that client-side tRPC calls use.
RSC server caller setup creates a server-side caller for use in React Server Components via createCallerFactory(appRouter)(createContext). This caller invokes procedures without HTTP overhead and is used in RSC async components to fetch data server-side with full type safety.
Client-side Provider setup wraps the application with QueryClientProvider and TRPCReactProvider in a client component, providing the React Query context needed for client-side tRPC hooks (trpc.procedureName.useQuery()).
tRPC v11 Patterns for Production Applications
Protected Procedures with Auth
Use tRPC middleware to enforce authentication on protected procedures. Create a protectedProcedure that checks ctx.session and throws a TRPCError({ code: 'UNAUTHORIZED' }) if the session is absent. All procedures built on protectedProcedure inherit the auth check and have the session typed as non-nullable in their handler context, eliminating null-check boilerplate throughout the codebase.
Input Validation with Zod
tRPC procedure inputs are validated at runtime using Zod schemas passed to .input(). The Zod schema simultaneously provides runtime validation, TypeScript types for the handler's input parameter, and client-side TypeScript type checking for the arguments passed to trpc.procedure.useQuery(input). This single schema definition replaces separate validation logic, TypeScript interfaces, and API documentation that would otherwise need maintenance in sync.
Streaming AI Responses
tRPC v11's async generator support makes streaming AI inference results natural. Define a procedure returning async function* that yields tokens from an LLM response, and consume it client-side with tRPC's subscription support. This enables streaming chat interfaces with full TypeScript typing on the streamed token shape, without manual SSE or WebSocket infrastructure.
Optimistic Updates with React Query
tRPC's React Query integration enables optimistic updates for mutation procedures. Use trpc.procedure.useMutation({ onMutate: async (input) => { await utils.procedure.cancel(); /* optimistic update */ } }) to update the local cache immediately while the mutation is in flight, with automatic rollback if the mutation fails. The React Query cache key management is handled automatically by tRPC.
Migration and Implementation Roadmap
create-t3-app CLI which scaffolds a complete tRPC + Prisma + NextAuth + Tailwind setup with correct v11 configuration. The T3 stack has accumulated years of production-proven patterns; starting from it rather than from scratch avoids common configuration pitfalls and provides a community-supported foundation.createCallerFactory for RSC usage replacing the v10 createServerSideHelpers, and updating error handling to use v11's typed error codes. The tRPC v11 migration guide documents all breaking changes; most teams complete the migration in 1–3 days depending on codebase size.staleTime and gcTime configuration to reduce unnecessary refetches. For RSC-rendered pages, use the server caller to avoid client-side waterfalls for initial page data.