oRPC: Typesafe APIs Made Simple with RPC and OpenAPI
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
oRPC combines RPC and OpenAPI to simplify building end-to-end type-safe APIs. It offers robust features like first-class OpenAPI support, contract-first development, and seamless integration with popular frameworks. This powerful tool ensures type safety from client to server while adhering to industry standards.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
oRPC is a powerful combination of RPC and OpenAPI, designed to make building APIs that are end-to-end type-safe and adhere to OpenAPI standards simple and efficient. It ensures type-safe inputs, outputs, and errors across your entire application stack, from client to server. With oRPC, developers can leverage contract-first development and integrate seamlessly with various frameworks and runtimes, enhancing both developer experience and application reliability.
Installation
To get started with oRPC, you can install the necessary packages using npm or your preferred package manager. The core packages include @orpc/server for backend implementation, @orpc/client for client-side consumption, and @orpc/contract for defining your API structure.
npm install @orpc/server @orpc/client @orpc/contract
Examples
Here's a quick overview of how to use oRPC, from defining your API router to consuming it and generating OpenAPI specifications.
1. Define your router
Start by defining your API procedures and their schemas using a schema validator like Zod.
import type { IncomingHttpHeaders } from 'node:http'
import { ORPCError, os } from '@orpc/server'
import * as z from 'zod'
const PlanetSchema = z.object({
id: z.number().int().min(1),
name: z.string(),
description: z.string().optional(),
})
export const listPlanet = os
.input(
z.object({
limit: z.number().int().min(1).max(100).optional(),
cursor: z.number().int().min(0).default(0),
}),
)
.handler(async ({ input }) => {
// your list code here
return [{ id: 1, name: 'name' }]
})
export const findPlanet = os
.input(PlanetSchema.pick({ id: true }))
.handler(async ({ input }) => {
// your find code here
return { id: 1, name: 'name' }
})
export const createPlanet = os
.$context<{ headers: IncomingHttpHeaders }>()
.use(({ context, next }) => {
const user = parseJWT(context.headers.authorization?.split(' ')[1])
if (user) {
return next({ context: { user } })
}
throw new ORPCError('UNAUTHORIZED')
})
.input(PlanetSchema.omit({ id: true }))
.handler(async ({ input, context }) => {
// your create code here
return { id: 1, name: 'name' }
})
export const router = {
planet: {
list: listPlanet,
find: findPlanet,
create: createPlanet
}
}
2. Create your server
Implement your oRPC server using a runtime-specific handler, for example, Node.js.
import { createServer } from 'node:http'
import { RPCHandler } from '@orpc/server/node'
import { CORSPlugin } from '@orpc/server/plugins'
const handler = new RPCHandler(router, {
plugins: [new CORSPlugin()]
})
const server = createServer(async (req, res) => {
const result = await handler.handle(req, res, {
context: { headers: req.headers }
})
if (!result.matched) {
res.statusCode = 404
res.end('No procedure matched')
}
})
server.listen(
3000,
'127.0.0.1',
() => console.log('Listening on 127.0.0.1:3000')
)
3. Create your client
Set up your client to interact with the oRPC server, ensuring type safety on the client side.
import type { RouterClient } from '@orpc/server'
import { createORPCClient } from '@orpc/client'
import { RPCLink } from '@orpc/client/fetch'
const link = new RPCLink({
url: 'http://127.0.0.1:3000',
headers: { Authorization: 'Bearer token' },
})
export const orpc: RouterClient<typeof router> = createORPCClient(link)
4. Consume your API
With the client configured, you can now consume your API with full type safety.
import { orpc } from './client'
const planets = await orpc.planet.list({ limit: 10 })
5. Generate OpenAPI Spec
oRPC allows you to generate OpenAPI specifications directly from your router definition.
import { OpenAPIGenerator } from '@orpc/openapi'
import { ZodToJsonSchemaConverter } from '@orpc/zod/zod4'
const generator = new OpenAPIGenerator({
schemaConverters: [new ZodToJsonSchemaConverter()]
})
const spec = await generator.generate(router, {
info: {
title: 'Planet API',
version: '1.0.0'
}
})
console.log(spec)
Why Use oRPC?
oRPC offers several compelling advantages for modern API development:
- End-to-End Type Safety: Guarantees type-safe data flow from client to server, reducing runtime errors and improving code reliability.
- First-Class OpenAPI: Provides native support for OpenAPI standards, simplifying API documentation, discovery, and integration with other tools.
- Contract-First Development: Supports defining API contracts before implementation, fostering better collaboration, consistency, and clearer expectations.
- Framework Integrations: Offers seamless integration with popular frontend frameworks and data fetching libraries such as TanStack Query, SWR, and Pinia Colada.
- Multi-Runtime Support: Designed to be fast and lightweight across various JavaScript runtimes, including Cloudflare Workers, Deno, Bun, and Node.js.
- Extendability: Easily extend functionality with a robust plugin system, middleware, and interceptors to tailor oRPC to your specific needs.
Links
- GitHub Repository: https://github.com/unnoq/orpc
- Official Documentation: https://orpc.dev
Related repositories
Similar repositories that may be relevant next.

code-session-memory: Automatic Vector Memory for AI Coding Sessions
August 15, 2026
code-session-memory provides automatic vector memory for various AI coding tools like OpenCode, Claude Code, Cursor, VS Code, Codex, and Gemini CLI. It indexes new messages into a vector database after each AI agent turn, enabling semantic search across all your past coding sessions. This tool ensures memory is shared across different platforms, enhancing developer productivity.

Cloudflare Computer: Give Your Agent a Virtual Filesystem
August 14, 2026
Cloudflare Computer is an innovative project that provides a virtual filesystem within a Durable Object, allowing agents to interact with a persistent state. It offers pluggable execution backends, including containerized Linux environments and serverless Workers, enabling flexible and powerful agent computing. Currently in preview, it's ideal for experiments and prototypes leveraging Cloudflare's edge infrastructure.

SwarmClaw: Self-Hosted AI Agent Runtime for Autonomous Swarms
August 13, 2026
SwarmClaw is an open-source, self-hosted AI agent runtime and multi-agent framework designed for autonomous agent swarms. It offers durable agent memory, MCP tools, schedules, and delegation, supporting over 23 LLM providers including Claude, GPT, Gemini, OpenRouter, and Ollama. This platform serves as a practical alternative to solutions like Claude Code and LangChain for those seeking self-hosted AI agent orchestration.

json-render: The Generative UI Framework for Dynamic Interfaces
August 12, 2026
json-render is a powerful Generative UI framework that allows developers to create dynamic, personalized user interfaces from natural language prompts. It ensures reliability by constraining AI-generated output to predefined components and actions, offering a predictable and safe way to build cross-platform UIs.
Source repository
Open the original repository on GitHub.
8 counted GitHub visits