orpc is a contract-first API development framework for TypeScript that starts with a shared contract definition and generates type-safe clients and servers from that single source of truth. It guarantees end-to-end type safety, meaning inputs, outputs, errors, and streaming data are all checked at compile time across the client–server boundary.
What distinguishes orpc from typical RPC frameworks is its ability to export contracts as OpenAPI specifications, to optimize server-side rendering by calling API handlers directly inside the server process, and to support real‑time bidirectional communication over WebSocket and server‑sent events. It also provides primitives for inter‑process messaging across workers, Electron processes, and browser scripts, as well as data fetching and mutation hooks that integrate with frontend query libraries like TanStack Query.
Beyond its core contract definition and client generation, orpc offers middleware pipelines, input/output schema validation (using Zod, Valibot, or ArkType), distributed tracing, structured logging, security plugins (CORS, CSRF, rate limiting, encryption), and integrations with many web frameworks including Next.js, Nuxt, Hono, Express, Fastify, Astro, and Solid Start. The framework is available as an npm package and includes tooling for automatic router generation, CLI generation from API definitions, and testing utilities for isolated procedure testing and contract mocking.