middleapi /orpc

Typesafe APIs Made Simple 🪄

★ 5,767⑂ 176👁 11⑃ 2,017● 333▤ 271
TypeScriptMITCreated 2024-09-27orpc.dev
下载:v1.16.2v1.16.2 ↓1.16.22026-11-06
+2
日增长
5,767
stars
176
forks
11
watchers
2,017
prs
333
issues
271
releases

README

oRPC - Typesafe APIs Made Simple 🪄


  
    
  
  
    
  
  
    
  
  
    
  
  
    
  
  
    
  


oRPC is a TypeScript framework for building end-to-end typesafe APIs. Write your API once as plain TypeScript functions, and oRPC gives you a fully typed client, a REST API with an OpenAPI document, and MCP tools for AI agents, with no code generation. It runs on Node.js, Bun, Deno, Cloudflare Workers, and more.

Define procedures on the server and serve them with an RPC handler:

ts
import { os } from '@orpc/server'
import  as z from 'zod'

export const router = {
  planet: {
    find: os
      .input(z.object({ id: z.number() }))
      .handler(({ input }) = ({ id: input.id, name: 'Earth' })),
  },
}


Then call them from a client that knows every input and output, without generating anything:

ts
import { createORPCClient } from '@orpc/client'
import { RPCLink } from '@orpc/client/fetch'
import type { RouterClient } from '@orpc/server'

import type { router } from './router'

const link = new RPCLink({ origin: 'http://localhost:3000', url: '/rpc' })
const client: RouterClient = createORPCClient(link)

const planet = await client.planet.find({ id: 1 }) // { id: number, name: string }


 Documentation

Read the full documentation at orpc.dev, starting with the Getting Started guide.

 Packages

Core

| Package                                                        | Purpose                                            | Docs                                                                                                                                                                                                                                                                     |
| -------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| @orpc/contract | Define API contract as the single source of truth. | Procedure Contract, Contract Router, Implementation, Generate from OpenAPI |
| @orpc/server     | Build APIs or implement contracts.                 | Procedure, Router, Middleware, Context, RPC Handler                                         |
| @orpc/client     | Consume APIs with end-to-end type safety.          | Client-Side Clients, Server-Side Clients, RPC Link, Error Handling                              |
| @orpc/openapi   | Add OpenAPI compatibility to APIs.                 | OpenAPI Handler, OpenAPI Link, Specification, Scalar                                               |

Schema validation

| Package                                                      | Purpose                                                    | Docs                                                  |
| ---------------------------------

Top issues

Discussions

Latest release

v1.16.2 v1.16.2 2026-11-06
   🐞 Bug Fixes

- client: Reject 3xx responses in RPCLink  -  by @dinwwwh in https://github.com/middleapi/orpc/issues/2429 (e6038)

     View changes on GitHub

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON