🌐
HTTP800K+/wkMIT

@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
npm install @trpc/server @trpc/client
yarn
yarn add @trpc/server @trpc/client
pnpm
pnpm add @trpc/server @trpc/client

Import

ESM
import { initTRPC } from '@trpc/server';

Quick Example

usage
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
CategoryHTTP
Weekly Downloads800K+
LicenseMIT
Installnpm install @trpc/server @trpc/client

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.