npm@trpc/serverv11.0.0
npmAdvanced

@trpc/server

End-to-end type-safe APIs — share TypeScript types between server and client without code generation.

typescriptapirpcfullstacknextjs
The Problem

You write a REST endpoint and manually duplicate its input/output types in the frontend. They drift apart. A field rename breaks the client silently. You add Zod schemas for validation, then OpenAPI for docs, then a codegen step to sync types. It's a lot of ceremony for what's just a function call.

Mental Model

tRPC removes the HTTP abstraction between frontend and backend. You define procedures (queries/mutations) on the server, and call them from the client as if they were local async functions. TypeScript infers all types across the boundary — no schemas, no codegen, no REST at all.

60-second start

Use it when

Full-stack TypeScript monorepos, Next.js apps where frontend and backend share a codebase, projects where you want type safety without REST/GraphQL ceremony.

Skip it when

Public APIs consumed by third parties (use REST or GraphQL). Polyglot teams where some consumers aren't TypeScript. Microservices with many separate repos.

Alternatives
GraphQL (Apollo)Language-agnostic, great for complex data graphs, third-party consumers.
REST + OpenAPIStandard, interoperable, better for public APIs.
ts-restREST with tRPC-like type safety — keeps HTTP semantics for when you need them.

Ready to explore the full API?

See every class, function, and relationship in an interactive graph.