Course contentsShow
← TypeScript
Lesson 1559 of 1,79636. tRPC and End-to-End Type SafetyFree lesson

Trade-offs: When tRPC Fits vs Doesn't

Understanding tRPC's limitations with public APIs, multiple clients, and non-TypeScript consumers.

Trade-offs: When tRPC Fits vs Doesn't

You'll learn: When to embrace tRPC's end-to-end type safety and when to look for alternatives based on your project's constraints.

Understanding tRPC's Limitations

While tRPC delivers incredible type safety for full-stack TypeScript applications, it's not a universal solution. The same design that makes it powerful—direct procedure calls with shared type definitions—also creates boundaries where it struggles.

Where tRPC Shines

tRPC excels in monorepo TypeScript projects where frontend and backend share the same codebase. When you control both ends of the communication and both are written in TypeScript, tRPC's type inference flows seamlessly. Your router defines the contract, and clients get autocomplete, type checking, and refactoring support automatically.

When tRPC Doesn't Fit

Public APIs: If you're building an API for external consumers, tRPC creates friction. External developers can't import your TypeScript router definitions. They need REST, GraphQL, or another language-agnostic protocol with documentation like OpenAPI specs.

Multiple Client Languages: Mobile apps in Swift or Kotlin, Python scripts, or third-party integrations can't use tRPC procedures. They need standard HTTP endpoints with predictable JSON contracts, not TypeScript-specific RPC calls.

Non-TypeScript Consumers: Even JavaScript-only projects miss out on tRPC's benefits. Without TypeScript's type system, they're making untyped procedure calls—no better than fetch with any types.

Separate Repositories: If your frontend and backend live in different repos with separate deployment cycles, sharing the router type becomes complex. You'd need to publish types as an npm package, which defeats tRPC's zero-configuration appeal.

WebSocket/REST Requirements: Teams with established REST conventions, OpenAPI tooling, or WebSocket needs may find tRPC's RPC model doesn't align with their architecture.

Key Takeaway: tRPC is optimal for monorepo TypeScript applications with full-stack control; use REST, GraphQL, or other standards when serving public APIs, non-TypeScript clients, or distributed teams with separate codebases.