PACKAGE · API

@trpc/server

The tRPC server library

WEEKLY DOWNLOADS 8.3M
STARS 40.9K
FORKS 1.8K
OPEN ISSUES 92
GZIP SIZE 7.2 kB
UNPACKED SIZE 1.9 MB
DEPENDENCIES 1
LAST UPDATED 9mo ago
DOWNLOAD TRENDS

@trpc/server downloads · last 12 months

Download trends for @trpc/server1 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.06.8M13.7M20.5M27.4MNov 2025FebMayAugOct 2026
@trpc/server
ABOUT @TRPC/SERVER

The @trpc/server package is the server library for tRPC, an API toolkit aimed at TypeScript applications. It lets developers define server-side procedures and expose them to clients with TypeScript types shared across the boundary, addressing the need to keep API inputs, outputs, and client calls aligned as code changes.

Its design centers on a typed, code-first API rather than separately maintaining an API description and generated client types. That approach suits teams building both ends of an application in TypeScript and willing to organize server functionality as procedures; it is less suited to clients that require a language-neutral API contract as their primary interface.

A typical server is configured with tRPC initialization, then composed from routers and procedures. Procedure builders can apply input validation and middleware, while query, mutation, and subscription patterns express different kinds of operations; the resulting router types provide the information client integrations use for typed calls.

The package is the server-side part of a broader tRPC workflow and is listed with topics including Next.js, Prisma, React, and TypeScript. It can be used with framework-specific adapters to connect a router to HTTP requests, while application code can put authorization, context creation, and data access around procedures; the package description does not specify particular adapter APIs or framework support details.

The listing reports a 7.2 kB gzip bundle size, 1.9 MB unpacked size, 8.4 million weekly downloads, and 40.9 thousand GitHub stars. It is MIT-licensed and was last updated on 2026-11-24; those figures indicate active use and maintenance, but do not establish runtime performance or compatibility with any particular project.

A key trade-off is the reliance on TypeScript types shared between server and client: independently developed clients or consumers in other languages may not benefit from that workflow without a separate contract. Teams should also decide how to validate untrusted inputs and handle authentication in their own procedures and middleware, since the package description does not claim those application policies are provided automatically.

WHEN TO USE
  • When building a TypeScript application with server and client code in the same codebase, define procedures in @trpc/server so client calls can use the router's inferred types.
  • When you want API operations organized as a router, compose related query and mutation procedures into routers and expose them through your server integration.
  • When request data needs validation before business logic runs, attach input validation to procedures so their inputs are checked at the server boundary.
  • When multiple procedures share request-scoped information or checks, use context and middleware patterns to centralize that behavior.
  • When integrating tRPC into a Next.js-oriented workflow, use @trpc/server to define the router and connect it through an appropriate server adapter.
  • When application clients need typed access to server operations, use the server router as the source of types for the corresponding tRPC client integration.
WHEN NOT TO USE
  • If your API must primarily serve clients written in multiple languages, choose a language-neutral API contract and expose endpoints against that contract; shared TypeScript router types will not serve as a universal client interface.
  • If clients must be generated from a separately published schema, use a schema-first API workflow instead of making the TypeScript server router the central contract.
  • If you are building only a conventional REST interface with established resource URLs and HTTP semantics, implement those endpoints directly rather than organizing the API around tRPC procedures.
  • If the server and client are maintained in separate repositories without a shared type-distribution workflow, publish or maintain an explicit API contract instead of relying on direct router type inference.
  • If you need framework-independent transport behavior without adopting tRPC's procedure model, use a general HTTP server and define the request and response contract directly.
  • If authentication, authorization, or input validation must be supplied as turnkey application policy, account for implementing those rules in context, middleware, and procedure validation rather than treating @trpc/server as a complete policy layer.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 5
@trpc/server vs @google/genai ★ 1.7K · 34.6M/wk @trpc/server vs googleapis ★ 12.3K · 13.1M/wk @trpc/server vs msw ★ 18.4K · 35.5M/wk @trpc/server vs openapi-typescript ★ 8.4K · 17.9M/wk @trpc/server vs graphql ★ 20.3K · 73.2M/wk