Course contentsShow
← React
Lesson 1821 of 2,39642. Data Fetching LibrariesFree lesson

When tRPC Fits vs GraphQL or REST

Evaluating tRPC for TypeScript full-stack projects; comparing to GraphQL for public APIs and REST for heterogeneous clients.

When tRPC Fits vs GraphQL or REST

You'll learn: How to decide when tRPC is the right choice versus GraphQL or traditional REST APIs for your project.

Understanding the Landscape

tRPC excels in TypeScript-only, full-stack projects where you control both the frontend and backend. It's like having a direct telephone line between your React app and Node.js server—no translation needed because everyone speaks TypeScript.

GraphQL shines when you need a public API consumed by multiple clients (mobile apps, third-party developers, non-TypeScript frontends). It's self-documenting, allows clients to request exactly the data they need, and works beautifully across different programming languages.

REST remains the gold standard for heterogeneous clients—when Android, iOS, Python scripts, and web apps all need access. REST's universality and simplicity (just URLs and HTTP methods) make it ideal when you can't guarantee TypeScript on both ends.

Decision Matrix

Choose tRPC when:

  • Your entire stack is TypeScript
  • You own both frontend and backend
  • Development speed and type safety matter most
  • Your API is private (internal use only)

Choose GraphQL when:

  • You have a public API with diverse consumers
  • Clients need flexible data fetching
  • You need strong API versioning and documentation
  • Multiple teams build different frontends

Choose REST when:

  • Clients use different languages/platforms
  • Simplicity and wide tooling support matter
  • You need HTTP caching at the CDN level
  • Your API is truly public-facing

Key Takeaway: tRPC is a TypeScript superpower for full-stack apps you control, but GraphQL and REST remain essential when your API serves the broader world beyond your TypeScript ecosystem.