oRPC is a TypeScript framework that combines Remote Procedure Call (RPC) patterns with OpenAPI specifications to enable end-to-end type-safe API development. The framework provides a unified approach to defining, implementing, and consuming APIs while maintaining full type safety across the client-server boundary and automatic OpenAPI spec generation.
The framework addresses the challenge of building APIs that are simultaneously type-safe for TypeScript consumers and standards-compliant for external integrations. It achieves this through a builder-based API definition system, pluggable schema validators, and multi-runtime server adapters.
For detailed information about fundamental concepts like type safety and the builder pattern, see Core Concepts. For architectural details, see Architecture Overview. For the complete package listing, see Package Ecosystem.
oRPC serves three primary functions:
os for server and oc for contract) to define procedures with input/output validation packages/server/package.json2-4 packages/contract/package.json2-4The framework supports two development approaches:
os builder and handlers.oc builder, then implement them separately using os.implement(contract).Sources: package.json1-47 apps/content/package.json11-45 packages/tanstack-query/package.json41-58
Sources: packages/client/README.md27-32 packages/server/README.md27-32 README.md27-32
| Package | Primary Responsibility | Key Concepts |
|---|---|---|
@orpc/shared | Common utilities and type helpers | EventPublisher, AsyncIteratorClass packages/shared/README.md1-25 |
@orpc/contract | Contract definition builder | oc, ContractProcedure, ContractRouter packages/contract/README.md27-32 |
@orpc/server | Server implementation builder | os, Procedure, Router, RPCHandler packages/server/README.md27-32 |
@orpc/client | Client creation and execution | createORPCClient, RPCLink packages/client/README.md27-32 |
@orpc/openapi | OpenAPI spec generation and handling | OpenAPIGenerator, OpenAPIHandler packages/openapi/README.md27-32 |
Sources: README.md27-32 packages/shared/README.md1-25
In this workflow, developers use the os builder from @orpc/server to define procedures that include both the schema validation and the implementation logic in one place. The client types are then inferred directly from the server router.
Sources: packages/server/README.md27-32 packages/client/README.md27-32
Developers use the oc builder from @orpc/contract to define the API shape (input, output, errors, metadata) without implementation. This contract can be shared between a server that implements it using os.implement(contract) and a client that consumes it using ContractRouterClient.
Sources: packages/contract/README.md27-32 packages/server/README.md27-32
oRPC supports multiple schema validation libraries through a converter pattern, allowing the same schema to be used for runtime validation and OpenAPI generation:
| Validator | Package | Notable Features |
|---|---|---|
| Zod | @orpc/zod | Integration with Zod schemas packages/zod/README.md36 |
| Valibot | @orpc/valibot | Integration with Valibot schemas README.md37 |
| ArkType | @orpc/arktype | Integration with ArkType schemas packages/arktype/package.json192-197 |
| JSON Schema | @orpc/json-schema | Smart coercion for OpenAPI requests README.md50 |
Sources: README.md34-38 packages/arktype/package.json186-190
The codebase is organized as a PNPM workspace monorepo package.json6 with a clear separation between core logic, schema adapters, and framework integrations:
Sources: package.json1-47 pnpm-lock.yaml1-130 packages/tanstack-query/package.json41-46
Foundational packages required for basic oRPC functionality:
@orpc/shared - Common utilities README.md55@orpc/contract - Contract definitions README.md29@orpc/client - Client-side consumption README.md31@orpc/server - Server-side implementation README.md30@orpc/openapi - OpenAPI integration README.md32Framework-specific client bindings:
@orpc/tanstack-query - Base TanStack Query integration packages/tanstack-query/package.json2-4@orpc/next - Next.js integration playgrounds/next/package.json22@orpc/opentelemetry - Instrument your API with OpenTelemetry README.md54@orpc/pino - Structured logging with Pino README.md55@orpc/ratelimit - Rate limiting features README.md49@orpc/publisher - Pub/Sub functionality README.md48Refresh this wiki
This wiki was recently refreshed. Please wait 5 days to refresh again.