{"id":22220264,"url":"https://github.com/unnoq/orpc","last_synced_at":"2025-05-14T02:04:29.842Z","repository":{"id":263099587,"uuid":"863811008","full_name":"unnoq/orpc","owner":"unnoq","description":"Typesafe APIs Made Simple 🪄","archived":false,"fork":false,"pushed_at":"2025-05-08T16:01:05.000Z","size":7182,"stargazers_count":1482,"open_issues_count":15,"forks_count":25,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-08T16:21:46.016Z","etag":null,"topics":["api","bunjs","cloudflare-worker","contract-first","denojs","next-js","nodejs","openapi","pinia-vuejs","react","rpc-api","solidjs","svelte","tanstack","typesafe","typescript","vue"],"latest_commit_sha":null,"homepage":"https://orpc.unnoq.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unnoq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["unnoq"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2024-09-27T00:43:26.000Z","updated_at":"2025-05-08T15:20:48.000Z","dependencies_parsed_at":"2024-12-07T10:17:58.572Z","dependency_job_id":"60f6b795-9b02-483a-9578-3b0992fa3252","html_url":"https://github.com/unnoq/orpc","commit_stats":null,"previous_names":["unnoq/orpc"],"tags_count":124,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unnoq%2Forpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unnoq%2Forpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unnoq%2Forpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unnoq%2Forpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unnoq","download_url":"https://codeload.github.com/unnoq/orpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253133127,"owners_count":21859111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bunjs","cloudflare-worker","contract-first","denojs","next-js","nodejs","openapi","pinia-vuejs","react","rpc-api","solidjs","svelte","tanstack","typesafe","typescript","vue"],"created_at":"2024-12-02T23:07:42.185Z","updated_at":"2025-05-14T02:04:29.833Z","avatar_url":"https://github.com/unnoq.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimage align=\"center\" src=\"https://orpc.unnoq.com/logo.webp\" width=280 alt=\"oRPC logo\" /\u003e\n\u003c/div\u003e\n\n\u003ch1\u003e\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://codecov.io/gh/unnoq/orpc\"\u003e\n    \u003cimg alt=\"codecov\" src=\"https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@orpc/client\"\u003e\n    \u003cimg alt=\"weekly downloads\" src=\"https://img.shields.io/npm/dw/%40orpc%2Fclient?logo=npm\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/unnoq/orpc/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"MIT License\" src=\"https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://discord.gg/TXEbwRBvQn\"\u003e\n    \u003cimg alt=\"Discord\" src=\"https://img.shields.io/discord/1308966753044398161?color=7389D8\u0026label\u0026logo=discord\u0026logoColor=ffffff\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003ch3 align=\"center\"\u003eTypesafe APIs Made Simple 🪄\u003c/h3\u003e\n\n**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards\n\n---\n\n## Highlights\n\n- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.\n- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.\n- **📝 Contract-First Development**: Optionally define your API contract before implementation.\n- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.\n- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.\n- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.\n- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.\n- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.\n- **📡 SSE \u0026 Streaming**: Enjoy full type-safe support for SSE and streaming.\n- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.\n- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.\n- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.\n\n## Documentation\n\nYou can find the full documentation [here](https://orpc.unnoq.com).\n\n## Packages\n\n- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.\n- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.\n- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.\n- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.\n- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.\n- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).\n- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).\n- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).\n- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).\n- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).\n- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.\n- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.\n- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).\n- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).\n\n## Overview\n\nThis is a quick overview of how to use oRPC. For more details, please refer to the [documentation](https://orpc.unnoq.com).\n\n1. **Define your router:**\n\n   ```ts\n   import type { IncomingHttpHeaders } from 'node:http'\n   import { ORPCError, os } from '@orpc/server'\n   import { z } from 'zod'\n\n   const PlanetSchema = z.object({\n     id: z.number().int().min(1),\n     name: z.string(),\n     description: z.string().optional(),\n   })\n\n   export const listPlanet = os\n     .input(\n       z.object({\n         limit: z.number().int().min(1).max(100).optional(),\n         cursor: z.number().int().min(0).default(0),\n       }),\n     )\n     .handler(async ({ input }) =\u003e {\n       // your list code here\n       return [{ id: 1, name: 'name' }]\n     })\n\n   export const findPlanet = os\n     .input(PlanetSchema.pick({ id: true }))\n     .handler(async ({ input }) =\u003e {\n       // your find code here\n       return { id: 1, name: 'name' }\n     })\n\n   export const createPlanet = os\n     .$context\u003c{ headers: IncomingHttpHeaders }\u003e()\n     .use(({ context, next }) =\u003e {\n       const user = parseJWT(context.headers.authorization?.split(' ')[1])\n\n       if (user) {\n         return next({ context: { user } })\n       }\n\n       throw new ORPCError('UNAUTHORIZED')\n     })\n     .input(PlanetSchema.omit({ id: true }))\n     .handler(async ({ input, context }) =\u003e {\n       // your create code here\n       return { id: 1, name: 'name' }\n     })\n\n   export const router = {\n     planet: {\n       list: listPlanet,\n       find: findPlanet,\n       create: createPlanet\n     }\n   }\n   ```\n\n2. **Create your server:**\n\n   ```ts\n   import { createServer } from 'node:http'\n   import { RPCHandler } from '@orpc/server/node'\n   import { CORSPlugin } from '@orpc/server/plugins'\n\n   const handler = new RPCHandler(router, {\n     plugins: [new CORSPlugin()]\n   })\n\n   const server = createServer(async (req, res) =\u003e {\n     const result = await handler.handle(req, res, {\n       context: { headers: req.headers }\n     })\n\n     if (!result.matched) {\n       res.statusCode = 404\n       res.end('No procedure matched')\n     }\n   })\n\n   server.listen(\n     3000,\n     '127.0.0.1',\n     () =\u003e console.log('Listening on 127.0.0.1:3000')\n   )\n   ```\n\n3. **Create your client:**\n\n   ```ts\n   import type { RouterClient } from '@orpc/server'\n   import { createORPCClient } from '@orpc/client'\n   import { RPCLink } from '@orpc/client/fetch'\n\n   const link = new RPCLink({\n     url: 'http://127.0.0.1:3000',\n     headers: { Authorization: 'Bearer token' },\n   })\n\n   export const orpc: RouterClient\u003ctypeof router\u003e = createORPCClient(link)\n   ```\n\n4. **Consume your API:**\n\n   ```ts\n   import { orpc } from './client'\n\n   const planets = await orpc.planet.list({ limit: 10 })\n   ```\n\n5. **Generate OpenAPI Spec:**\n\n   ```ts\n   import { OpenAPIGenerator } from '@orpc/openapi'\n   import { ZodToJsonSchemaConverter } from '@orpc/zod'\n\n   const generator = new OpenAPIGenerator({\n     schemaConverters: [new ZodToJsonSchemaConverter()]\n   })\n\n   const spec = await generator.generate(router, {\n     info: {\n       title: 'Planet API',\n       version: '1.0.0'\n     }\n   })\n\n   console.log(spec)\n   ```\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg\"\u003e\n    \u003cimg src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## References\n\noRPC is inspired by existing solutions that prioritize type safety and developer experience. Special acknowledgments to:\n\n- [tRPC](https://trpc.io): For pioneering the concept of end-to-end type-safe RPC and influencing the development of type-safe APIs.\n- [ts-rest](https://ts-rest.com): For its emphasis on contract-first development and OpenAPI integration, which have greatly inspired oRPC’s feature set.\n\n## License\n\nDistributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.\n","funding_links":["https://github.com/sponsors/unnoq"],"categories":["TypeScript","**1. Libraries**"],"sub_categories":["APIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funnoq%2Forpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funnoq%2Forpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funnoq%2Forpc/lists"}