@trpc/server
tRPC enables you to build fully typesafe APIs without schemas or code generation by leveraging TypeScript's type inference to share types between server and cli…
Installation
npm install @trpc/server @trpc/client
yarn add @trpc/server @trpc/client
pnpm add @trpc/server @trpc/client
Import
import { initTRPC } from '@trpc/server';Quick Example
import { initTRPC } from '@trpc/server';
const t = initTRPC.create();
export const appRouter = t.router({
hello: t.procedure
.input(z.string())
.query(({ input }) => `Hello ${input}`),
});About @trpc/server
tRPC enables you to build fully typesafe APIs without schemas or code generation by leveraging TypeScript's type inference to share types between server and client automatically. With tRPC, you define procedures (queries, mutations, subscriptions) on the server using a fluent builder API, and the client automatically knows the input types, output types, and available endpoints without any manual type definitions or code generation step. This eliminates the entire category of API contract bugs where client and server disagree on request or response shapes. tRPC supports input validation using Zod, Yup, or any validation library, middleware for authentication and authorization, context creation for per-request data like user sessions, and subscriptions for real-time updates. The framework integrates with Next.js, Express, Fastify, and standalone Node.js servers, with React Query integration providing automatic caching, invalidation, and optimistic updates on the client. tRPC is particularly powerful in monorepo setups where server and client share a TypeScript codebase, enabling the fastest possible iteration speed for full-stack TypeScript applications.
Quick Facts
| Package | @trpc/server |
| Category | HTTP |
| Weekly Downloads | 800K+ |
| License | MIT |
| Install | npm install @trpc/server @trpc/client |
Related Packages
Zod is a TypeScript-first schema validation library that provides a concise, chainable API for defin…
Next.js is the leading React framework for building full-stack web applications, developed and maint…
Express is the most widely used web application framework for Node.js, providing a minimal and flexi…
GraphQL is the JavaScript reference implementation of the GraphQL specification, a query language fo…
TypeScript is a strongly typed programming language that builds on JavaScript, adding static type de…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.