Libraries
Framework
Start
Router
Data & State
Query
DB
Store
AI
UI
Table
Charts
Form
Markdown
Highlight
UX
Virtual
Pacer
Hotkeys
Tooling
Devtools
Config
CLI
Intent
Browse all libraries
Blog
Blog & Release Notes
About
YouTube
The official TanStack channel.
Workshops
Live sessions from the maintainers.
Release Notes
The latest releases and changelog.
Community
Channels
Discord
Real-time community support.
GitHub
Source, issues, discussions, and releases.
People & Work
Maintainers
Meet the people maintaining the stack.
Showcase
Projects selected by the TanStack team.
Community projects
Tools
Tools
Application Starter
Alpha
Generate TanStack app starters.
Builder
Alpha
Build and share TanStack projects.
Stats
NPM and ecosystem usage data.
Merch
View all
Support
Support
Support Overview
Find the right support path.
Partners
Companies supporting TanStack.
OSS Sponsors
Sponsors keeping TanStack open source.
Enterprise Support
Private consulting and expert support.
Contact
Get in touch with the TanStack team.
About
Ethos
How we approach open source.
Tenets
The values that shape TanStack libraries.
Design System
Logos, tokens, and UI components.
Search
Ask AI
Libraries
Blog
Community
Tools
Merch
Support
Search
Ask AI
Sign In
Back
TanStack Intent
/
Registry
/
@trpc/server
Fetching package from npm...
TanStack Intent
/
Registry
/
@trpc/server
@trpc/server
11.19.1-canary.0.sha-8b649ad87 (latest) — 16 skills
11.19.0 — 16 skills
11.18.1-canary.13 — 16 skills
11.18.1-canary.30 — 16 skills
11.18.1-canary.9 — 16 skills
11.18.1-canary.19 — 16 skills
11.18.1-canary.18 — 16 skills
11.18.1-canary.35.sha-573d4f33e — 16 skills
11.18.1-canary.34.sha-3a77dc4d6 — 16 skills
11.18.1-canary.17 — 16 skills
11.18.1-canary.11 — 16 skills
11.18.1-canary.15 — 16 skills
11.18.1-canary.6 — 16 skills
11.18.1-canary.5 — 16 skills
11.18.1-canary.2 — 16 skills
11.18.1-canary.1 — 16 skills
11.18.0 — 16 skills
11.17.1-canary.3 — 16 skills
11.17.1-canary.2 — 16 skills
11.17.0 — 16 skills
11.16.1-canary.20 — 16 skills
11.16.1-canary.17 — 16 skills
11.16.1-canary.6 — 16 skills
11.16.1-canary.5 — 16 skills
11.16.1-canary.4 — 16 skills
11.16.1-canary.3 — 16 skills
11.16.1-canary.2 — 16 skills
11.16.1-canary.1 — 16 skills
11.16.0 — 16 skills
11.15.2 — 16 skills
11.15.2-canary.3 — 16 skills
11.15.2-canary.2 — 16 skills
11.15.1 — 16 skills
11.15.1-canary.2 — 16 skills
11.15.0 — 16 skills
11.14.2-canary.5 — 16 skills
11.14.1 — 16 skills
Copy install prompt
The tRPC server library
Skills
(16)
Skills
All Skills
16
adapter-aws-lambda
core
adapter-express
core
adapter-fastify
core
adapter-fetch
core
adapter-standalone
core
auth
composition
caching
core
error-handling
core
middlewares
core
non-json-content-types
core
server-setup
core
server-side-calls
core
service-oriented-architecture
composition
subscriptions
core
trpc-router
core
validators
core
Skills
16
History
adapter-aws-lambda
core
Deploy tRPC on AWS Lambda with awsLambdaRequestHandler() from @trpc/server/adapters/aws-lambda for API Gateway v1 (REST, APIGatewayProxyEvent) and v2 (HTTP, APIGatewayProxyEventV2), and Lambda Function URLs. Enable response streaming with awsLambdaStreamingRequestHandler() wrapped in awslambda.streamifyResponse(). CreateAWSLambdaContextOptions provides event and context for context creation.
204 lines
adapter-express
core
Mount tRPC as Express middleware with createExpressMiddleware() from @trpc/server/adapters/express. Access Express req/res in createContext via CreateExpressContextOptions. Mount at a path prefix like app.use('/trpc', ...). Avoid global express.json() conflicting with tRPC body parsing for FormData.
177 lines
adapter-fastify
core
Mount tRPC as a Fastify plugin with fastifyTRPCPlugin from @trpc/server/adapters/fastify. Configure prefix, trpcOptions (router, createContext, onError). Enable WebSocket subscriptions with useWSS and @fastify/websocket. Set routerOptions.maxParamLength for batch requests. Requires Fastify v5+. FastifyTRPCPluginOptions for type-safe onError. CreateFastifyContextOptions provides req, res.
222 lines
adapter-fetch
core
Deploy tRPC on WinterCG-compliant edge runtimes with fetchRequestHandler() from @trpc/server/adapters/fetch. Supports Cloudflare Workers, Deno Deploy, Vercel Edge Runtime, Astro, Remix, SolidStart. FetchCreateContextFnOptions provides req (Request) and resHeaders (Headers) for context creation. The endpoint option must match the URL path prefix where the handler is mounted.
200 lines
adapter-standalone
core
Mount tRPC on Node.js built-in HTTP server with createHTTPServer() from @trpc/server/adapters/standalone, createHTTPHandler() for custom http.createServer, createHTTP2Handler() for HTTP/2 with TLS. Configure basePath to slice URL prefix, CORS via the cors npm package passed as middleware option. CreateHTTPContextOptions provides req and res for context creation.
199 lines
auth
composition
Implement JWT/cookie authentication and authorization in tRPC using createContext for user extraction, t.middleware with opts.next({ ctx }) for context narrowing to non-null user, protectedProcedure base pattern, client-side Authorization headers via httpBatchLink headers(), WebSocket connectionParams, and SSE auth via cookies or EventSource polyfill custom headers.
343 lines
caching
core
Set HTTP cache headers on tRPC query responses via responseMeta callback for CDN and browser caching. Configure Cache-Control, s-maxage, stale-while-revalidate. Handle caching with batching and authenticated requests. Avoid caching mutations, errors, and authenticated responses.
206 lines
error-handling
core
Throw typed errors with TRPCError and error codes (NOT_FOUND, UNAUTHORIZED, BAD_REQUEST, INTERNAL_SERVER_ERROR), configure errorFormatter for client-side Zod error display, handle errors globally with onError callback, map tRPC errors to HTTP status codes with getHTTPStatusCodeFromError().
254 lines
middlewares
core
Create and compose tRPC middleware with t.procedure.use(), extend context via opts.next({ ctx }), build reusable middleware with .concat() and .unstable_pipe(), define base procedures like publicProcedure and authedProcedure. Access raw input with getRawInput(). Logging, timing, OTEL tracing patterns.
243 lines
non-json-content-types
core
Handle FormData, file uploads, Blob, Uint8Array, and ReadableStream inputs in tRPC mutations. Use octetInputParser from @trpc/server/http for binary data. Route non-JSON requests with splitLink and isNonJsonSerializable() from @trpc/client. FormData and binary inputs only work with mutations (POST).
266 lines
server-setup
core
Initialize tRPC with initTRPC.create(), define routers with t.router(), create procedures with .query()/.mutation()/.subscription(), configure context with createContext(), export AppRouter type, merge routers with t.mergeRouters(), lazy-load routers with lazy().
379 lines
server-side-calls
core
Call tRPC procedures directly from server code using t.createCallerFactory() and router.createCaller(context) for integration testing, internal server logic, and custom API endpoints. Catch TRPCError and extract HTTP status with getHTTPStatusCodeFromError(). Error handling via onError option.
250 lines
service-oriented-architecture
composition
Break a tRPC backend into multiple services with custom routing links that split on the first path segment (op.path.split('.')) to route to different backend service URLs. Define a faux gateway router that merges service routers for the AppRouter type without running them in the same process. Share procedure and router definitions via a server-lib package with a single initTRPC instance. Each service runs its own standalone/Express/Fastify server.
248 lines
subscriptions
core
Set up real-time event streams with async generator subscriptions using .subscription(async function*() { yield }). SSE via httpSubscriptionLink is recommended over WebSocket. Use tracked(id, data) from @trpc/server for reconnection recovery with lastEventId. WebSocket via wsLink and createWSClient from @trpc/client, applyWSSHandler from @trpc/server/adapters/ws. Configure SSE ping with initTRPC.create({ sse: { ping: { enabled, intervalMs } } }). AbortSignal via opts.signal for cleanup. splitLink to route subscriptions.
407 lines
trpc-router
core
Entry point for all tRPC skills. Decision tree routing by task: initTRPC.create(), t.router(), t.procedure, createTRPCClient, adapters, subscriptions, React Query, Next.js, links, middleware, validators, error handling, caching, FormData.
152 lines
validators
core
Configure input and output validation with .input() and .output() using Zod, Yup, Superstruct, ArkType, Valibot, Effect, or custom validator functions. Chain multiple .input() calls to merge object schemas. Standard Schema protocol support. Output validation returns INTERNAL_SERVER_ERROR on failure.
229 lines