Key features
- End-to-end type safety — inputs, outputs, and errors are typed from server to client.
- First-class OpenAPI — generate a compliant spec from your router with no extra annotations.
- Contract-first development — optionally define your API contract before writing handlers.
- No code generation — your TypeScript types are your contract.
- Native types —
Date,File,Blob,BigInt,URLwork without serialization wrappers. - SSE and streaming — full type-safe server-sent events and streaming responses.
- Multi-runtime — runs on Node.js, Cloudflare Workers, Deno, Bun, and any Fetch-compatible environment.
- Standard Schema support — works with Zod, Valibot, ArkType, and more.
- OpenTelemetry — built-in observability integration via
@orpc/otel.
oRPC vs tRPC
tRPC pioneered end-to-end type-safe RPC in TypeScript, and oRPC owes it a lot. If you’re happy with tRPC and don’t need OpenAPI or contract-first workflows, tRPC is a solid choice.| oRPC | tRPC | |
|---|---|---|
| End-to-end type safety | Yes | Yes |
| OpenAPI generation | Built-in | Requires adapters / workarounds |
| Contract-first | Yes (@orpc/contract) | No |
| Native types (Date, File, Blob) | Yes | Requires transformers |
| SSE / streaming | Yes | Yes (experimental) |
| Multi-runtime | Yes | Depends on adapter |
| Code generation | No | No |
- You need to publish an OpenAPI spec for external consumers or partner integrations.
- You want to define an API contract that separate teams can implement against.
- You work with native types like
FileorBlobwithout custom serializers.
oRPC vs ts-rest
ts-rest takes a REST/OpenAPI-first approach that inspired oRPC’s contract layer. ts-rest is excellent if your team wants to stay close to HTTP conventions and you already have an OpenAPI spec.| oRPC | ts-rest | |
|---|---|---|
| End-to-end type safety | Yes | Yes |
| OpenAPI generation | Built-in | Built-in |
| Client style | Typed function calls | Typed fetch client |
| Native types (Date, File, Blob) | Yes | Limited |
| SSE / streaming | Yes | Limited |
| Runtime-agnostic | Yes | Yes |
| Schema validators | Zod, Valibot, ArkType, … | Zod |
- You prefer calling procedures as typed functions rather than constructing HTTP requests.
- You want to use Valibot, ArkType, or another schema validator alongside Zod.
- You need streaming or SSE with full type safety.
- You want middleware-based context enrichment (e.g., auth, logging) baked into the procedure chain.
When not to use oRPC
oRPC is not the right fit if:- You have an existing REST API that you don’t control and only need a typed client — use
openapi-typescriptor Hey API instead. - Your team strongly prefers a REST architecture with manually defined routes and HTTP verbs over an RPC mental model.
The oRPC approach
oRPC builds on two simple ideas:- Procedures — a single async function with typed input, typed output, and typed errors.
- Routers — a plain object that nests procedures into a hierarchy.
Quickstart
Build your first oRPC API in five minutes.
Core concepts
Understand procedures, routers, middleware, and context.
