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 and oc builders) to define procedures with input/output validation.RPCHandler and OpenAPIHandler.The framework supports two development approaches:
os builder and handlers.oc builder, then implement separately.Sources: README.md1-219 package.json1-66 packages/server/package.json1-154 packages/client/package.json1-75 packages/contract/package.json1-53
Sources: packages/server/package.json132-141 packages/client/package.json66-70 packages/contract/package.json42-44
| Package | Location | Primary Responsibility | Key Exports |
|---|---|---|---|
@orpc/shared | packages/shared/package.json1-54 | Common utilities and type helpers | EventPublisher, AsyncIteratorClass, type utilities |
@orpc/contract | packages/contract/package.json1-53 | Contract definition builder | oc, ContractProcedure, ContractRouter |
@orpc/server | packages/server/package.json1-154 | Server implementation builder | os, Procedure, Router, RPCHandler |
@orpc/client | packages/client/package.json1-75 | Client creation and execution | createORPCClient, RPCLink |
@orpc/openapi | packages/openapi/package.json1-87 | OpenAPI spec generation and handling | OpenAPIGenerator, OpenAPIHandler |
Sources: pnpm-lock.yaml11-1064 packages/shared/package.json1-54 packages/contract/package.json1-53 packages/server/package.json1-154
Sources: packages/server/package.json94-110 packages/client/package.json49-56
Sources: packages/contract/package.json29-32 packages/server/package.json133
The framework uses a standard server interface pattern to support multiple runtimes. All adapters implement the StandardHandlerPlugin interface from @orpc/standard-server.
Sources: packages/server/package.json37-91 packages/openapi/package.json27-52
oRPC supports multiple schema validation libraries through a converter pattern:
| Validator | Package | Converter Class | JSON Schema Support |
|---|---|---|---|
| Zod | @orpc/zod | ZodToJsonSchemaConverter | Yes |
| Valibot | @orpc/valibot | ValibotConverter | Yes |
| ArkType | @orpc/arktype | ArktypeConverter | Yes |
All validators implement the Standard Schema specification (@standard-schema/spec) for runtime validation.
Sources: packages/zod/package.json46-52 packages/contract/package.json44 packages/shared/package.json47-52
The codebase is organized as a PNPM workspace monorepo with the following structure:
Sources: package.json1-67 pnpm-lock.yaml1-105
Foundational packages required for basic oRPC functionality:
@orpc/shared - Common utilities packages/shared/package.json1-54@orpc/contract - Contract definitions packages/contract/package.json1-53@orpc/client - Client-side consumption packages/client/package.json1-75@orpc/server - Server-side implementation packages/server/package.json1-154@orpc/openapi - OpenAPI integration packages/openapi/package.json1-87Runtime-specific adapters for server deployment:
@orpc/standard-server - Base adapter interface packages/server/package.json136@orpc/standard-server-fetch - Fetch API adapter packages/server/package.json139@orpc/standard-server-node - Node.js HTTP adapter packages/server/package.json140@orpc/standard-server-fastify - Fastify adapter packages/server/package.json138@orpc/standard-server-aws-lambda - AWS Lambda adapter packages/server/package.json137Schema validation and OpenAPI conversion:
@orpc/zod - Zod integration packages/zod/package.json1-57@orpc/valibot - Valibot integration packages/shared/package.json50@orpc/arktype - ArkType integration packages/shared/package.json49Framework-specific client bindings:
@orpc/tanstack-query - Base TanStack Query integration packages/tanstack-query/package.json1-56@orpc/react-query - React Query hooks packages/react-query/package.json@orpc/vue-query - Vue Query composables packages/vue-query/package.json@orpc/react - React utilities and Server Actions packages/react/package.jsonSpecialized capabilities:
@orpc/nest - NestJS integration packages/nest/package.json@orpc/ai-sdk - Vercel AI SDK integration packages/ai-sdk/package.json@orpc/otel - OpenTelemetry tracing apps/content/package.json25@orpc/experimental-ratelimit - Rate limiting apps/content/package.json21Sources: README.md packages/shared/package.json1-54 packages/server/package.json1-154
Refresh this wiki