๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
๋ฒ„์ „: 9.x
tRPC

End-to-end typesafe APIs made easy

codecovGitHub LicenseGitHub Stars

Watch Video

Alex / KATT and Prisma's Mahmoud Abdelwahab doing a deep dive into tRPC.

Introductionโ€‹

tRPC allows you to easily build & consume fully typesafe APIs, without schemas or code generation.

As TypeScript and static typing increasingly becomes a best practice in web programming, the API presents a major pain point. We need better ways to statically type our API endpoints and share those types between our client and server (or server-to-server). We set out to build a simple library for building typesafe APIs that leverages the full power of modern TypeScript. Introducing tRPC!

An alternative to traditional REST or GraphQLโ€‹

Currently GraphQL is the dominant way to implement typesafe APIs in TypeScript (and it's amazing!). Since GraphQL is designed as a language-agnostic specification for implementing APIs, it doesn't take full advantage of the power of a language like TypeScript - further reading.

If your project is built with full-stack TypeScript, you can share types directly between your client and server, without relying on code generation.

Featuresโ€‹

  • โœ…ย  Well-tested and production ready.
  • ๐Ÿง™โ€โ™‚๏ธย  Full static typesafety & autocompletion on the client, for inputs, outputs and errors.
  • ๐ŸŽย  Snappy DX - No code generation, run-time bloat, or build pipeline.
  • ๐Ÿƒย  Light - tRPC has zero deps and a tiny client-side footprint.
  • ๐Ÿปย  Easy to add to your existing brownfield project.
  • ๐Ÿ”‹ย  Batteries included - React.js/Next.js/Express.js/Fastify adapters. (But tRPC is not tied to React and there are many community adapters for other libraries)
  • ๐Ÿฅƒย  Subscriptions support.
  • โšก๏ธย  Request batching - requests made at the same time can be automatically combined into one.
  • ๐Ÿ‘€ย  Quite a few examples that you can use for reference or as a starting point.