@orpc/server is the core server-side package for oRPC. It lets you define procedures, compose routers, attach middleware, and serve requests over HTTP or any other transport.
Installation
The os builder
Everything starts with the os export — a pre-configured Builder instance you use to define procedures, middleware, and routers.
os instance is never mutated. This means you can safely derive shared base builders:
Quick example
What’s in this section
Procedures
Define typed inputs, outputs, errors, and handlers.
Routers
Compose procedures into nested routers.
Middleware
Intercept and transform the pipeline with middleware.
Context
Pass request-scoped data through the call stack.
Errors
Typed, serializable errors with ORPCError.
Contract-First
Define the API shape before implementing it.
Adapters
Plug in to Node.js, Fetch, Fastify, AWS Lambda, and more.
Plugins
CORS, batching, CSRF protection, and response headers.
Server Actions
Use oRPC procedures as Next.js Server Actions.
Streaming & SSE
Stream responses with typed async iterators.
WebSockets
Real-time two-way communication over WebSockets.
OpenTelemetry
Distributed tracing with @orpc/otel.
NestJS
Deep integration with the NestJS framework.
