← Back to archive

Repo of the Day

dinwwwh/orpc

Published: Aug 6, 2025

Open repository ↗

Typesafe APIs Made Simple 🪄

Summary

oRPC is a TypeScript library for building typesafe APIs using a contract-first approach. A shared procedure contract acts as the single source of truth, with separate packages for server implementation, client consumption, and OpenAPI compatibility. The project is distributed as a monorepo of over 20 packages covering schema validation, pub/sub, rate limiting, observability, and framework integrations.

What it is useful for

oRPC fits teams that want end-to-end type safety between their TypeScript client and server without manually keeping types in sync. The @orpc/contract package lets you describe each procedure's input, output, and errors once, then reuse that description to implement the server (@orpc/server) and to call the API from the client (@orpc/client).

It is also useful when you need both an RPC and a REST surface from the same code: @orpc/openapi adds an OpenAPI specification and handler to the same contracts, so the same procedures can serve typed RPC clients and OpenAPI consumers. Schema validation is pluggable through adapters for Zod (@orpc/zod), Valibot (@orpc/valibot), and ArkType (@orpc/arktype).

Beyond core RPC, the project ships helpers that normally require separate services: a publisher for pub/sub with memory, Redis, and Upstash adapters, a rate limiter, a distributed lock, and Cloudflare Hibernation WebSocket support. Framework integrations cover Next.js, TanStack Query, SWR, Pinia Colada, NestJS, Bun, and Cloudflare Workers, plus an adapter (@orpc/trpc) that lets existing tRPC routers be reused inside oRPC.

How engineers can use it

A typical setup involves installing the relevant packages from the @orpc/* scope on npm and importing a few symbols to wire client, server, and contract together. Because the README does not include copy-pasteable install commands or a full code example, the exact steps, API surface, and configuration options should be read in the official documentation at orpc.dev, which covers procedure definition, routers, middleware, context, and error handling on both sides.

For existing tRPC codebases, @orpc/trpc allows reusing current routers rather than rewriting them. For testing, @orpc/experimental-msw mocks procedures with Mock Service Worker. Observability hooks are available through @orpc/opentelemetry, @orpc/pino, and @orpc/evlog. Note that several packages are explicitly labeled experimental (lock, MSW, Effect), so they may not be production-ready, and @orpc/openapi is an opt-in add-on rather than enabled by default.