ProducttRPC
Websitetrpc.io
CategoryAPI Framework / TypeScript
ApproachType inference from server to client (no codegen)
PricingFree and open source

What Is tRPC?

tRPC creates end-to-end type-safe APIs by directly sharing TypeScript types between your server and client. There is no schema language, no code generation, and no REST or GraphQL. You define a procedure on the server with a Zod input schema and a return type, and the client automatically knows the input type, the output type, and the procedure name. The types flow through TypeScript’s inference, not through a build step.

The insight is that when both your server and client are TypeScript, you don’t need an intermediate schema language. GraphQL exists because clients and servers might be different languages. OpenAPI exists for the same reason. But if both sides are TypeScript, the type system is the schema, and tRPC makes it the API contract.

Key Features

Zero Code Generation

tRPC uses TypeScript’s type inference to share types between server and client. There’s no generate command, no build step, no schema file. When you add a new field to a server procedure, the client type updates immediately. Rename a procedure, and every call site shows an error instantly. The feedback loop is measured in milliseconds, not build cycles.

Input Validation With Zod

Define input schemas with Zod, and tRPC validates inputs at runtime while inferring types at compile time. The same schema serves double duty: it validates that the client sent correct data AND it tells the client what data to send. One source of truth for validation and types.

React Query Integration

tRPC’s React client wraps React Query (TanStack Query), giving you type-safe useQuery and useMutation hooks. Caching, background refetching, optimistic updates, and infinite queries all work with full type inference. The developer experience is React Query with automatic type safety.

Subscriptions

tRPC supports WebSocket subscriptions with the same type-safe pattern as queries and mutations. Define a subscription on the server, and the client hook knows the event type. Useful for real-time features like notifications, chat, and live updates.

Who Is This For?

Pros

  • Zero code generation (types inferred by TypeScript)
  • End-to-end type safety (server to client)
  • React Query integration with automatic types
  • Input validation with Zod
  • Fastest API development cycle (change server, client updates immediately)
  • WebSocket subscriptions with type safety

Cons

  • TypeScript-only (no non-TypeScript clients)
  • Monorepo or shared types required
  • Not suitable for public APIs (no schema for external consumers)
  • Tight coupling between server and client
  • Not RESTful (no standard HTTP methods/status codes)

Verdict

tRPC is the most productive way to build APIs when both your server and client are TypeScript. The zero-code-generation approach means the type feedback is instant: change a server procedure, and every invalid client call shows a TypeScript error before you save the file. No other API approach achieves this speed of feedback.

The constraint is the strength: tRPC works because it’s TypeScript-to-TypeScript. If you need to expose an API to non-TypeScript clients, mobile apps, or third parties, you need REST or GraphQL. But for internal full-stack TypeScript applications — which is most of what gets built with Next.js — tRPC eliminates an entire category of boilerplate and bugs.

Build an API framework or TypeScript tool?

Get reviewed and linked from our 27-site network. Placements live in 48 hours.

See Packages