tRPC
End-to-end typesafe APIs for TypeScript — no schemas, no codegen. Define procedures on the backend; the client calls them with full type safety. The fastest way to build a TS full-stack app. No REST/GraphQL needed — just functions.
- TypeScript full-stack apps.
- Internal APIs between frontend and backend.
- When you want type safety without schemas.
- Public APIs (use REST/GraphQL).
- Polyglot stacks (not TS-only).
- When you need a separate API contract.
Definition
tRPC lets you define backend procedures (queries, mutations) and call them from the frontend with full type safety. The client imports the router type and calls procedures like functions — TypeScript infers types automatically. Works with Next.js, Express, Fastify.
Why it exists
REST/GraphQL require schemas and codegen. tRPC removes that — the TypeScript compiler IS the API contract. If it compiles, the types are correct. No schema drift.
How it works
Define a router with procedures (publicProcedure.query()/.mutation()). Export the AppRouter type. Client creates a caller with that type. Calls are type-safe HTTP requests under the hood. Supports subscriptions (WebSocket).
Scaling limits
TypeScript-only (not for polyglot APIs). No public REST API (internal APIs only). Couples frontend and backend. Less ecosystem than REST/GraphQL.
Cost shape
Free and open source.
Alternatives
- REST — Language-agnostic, more boilerplate, no type safety.
- GraphQL — Flexible queries, schema overhead, codegen.
Failure modes
- TS-only limitation.
- No public API.
- Frontend/backend coupling.
- Schema-less can hide breaking changes.