Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions apps/content/docs/adapters/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "Adapters"
description: "Pick the oRPC adapter for your runtime, framework, or messaging channel, from the Fetch API and Node HTTP to Next.js, Hono, WebSocket, and Electron."
seo:
title: "Adapters: Run oRPC on Any Runtime or Framework"
sidebar:
hidden: true
---

An adapter connects a handler to where your code runs. The router stays the same, so switching hosts only changes the few lines that mount the handler. HTTP adapters serve both the [RPC Handler](/docs/rpc/handler) and the [OpenAPI Handler](/docs/openapi/handler).

## Core

- [Fetch API](/docs/adapters/fetch-api): Bun, Deno, and anything built on `Request` and `Response`.
- [Node HTTP](/docs/adapters/node-http): Node's `http`, `https`, and `http2` servers.
- [Fastify](/docs/adapters/fastify): Fastify servers.
- [AWS Lambda](/docs/adapters/aws-lambda): API Gateway and Function URLs, with response streaming.
- [WebSocket](/docs/adapters/websocket): ws, crossws, Bun, Deno, Cloudflare, and uWebSockets.
- [Message Port](/docs/adapters/message-port): iframes, workers, and other contexts linked by a `MessagePort`.

## Frameworks

Built on the Fetch API: [Next.js](/docs/adapters/next), [Nuxt](/docs/adapters/nuxt), [SvelteKit](/docs/adapters/svelte-kit), [TanStack Start](/docs/adapters/tanstack-start), [SolidStart](/docs/adapters/solid-start), [React Router](/docs/adapters/react-router), [Astro](/docs/adapters/astro), [Hono](/docs/adapters/hono), [Elysia](/docs/adapters/elysia), and [H3](/docs/adapters/h3). Built on Node HTTP: [Express.js](/docs/adapters/express).

## Platforms

- [Cloudflare Workers](/docs/adapters/cloudflare-workers): the Fetch API Adapter plus the compatibility flags it needs.
- [Expo](/docs/adapters/expo): call oRPC from a React Native app.

## Between Contexts

Built on the Message Port Adapter: [Browser](/docs/adapters/browser) (extensions and windows), [Electron](/docs/adapters/electron), [Web Workers](/docs/adapters/web-workers), and [Worker Threads](/docs/adapters/worker-threads).
18 changes: 18 additions & 0 deletions apps/content/docs/client/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: "Client"
description: "Call oRPC procedures with full type safety from browsers, apps, and servers: create clients over links, call locally during SSR, handle errors, and stream."
seo:
title: "Clients: Call Procedures with End-to-End Types"
sidebar:
hidden: true
---

A client calls procedures like local functions, typed from your router or contract. Client-side clients call a server through a link, such as the [RPC Link](/docs/rpc/link) or [OpenAPI Link](/docs/openapi/link). Server-side clients call procedures in the same process.

- [Server-Side Clients](/docs/client/server-side): call procedures directly, without HTTP.
- [Client-Side Clients](/docs/client/client-side): create a client over a link, with context and interceptors.
- [Error Handling](/docs/client/error-handling): handle errors with `try/catch` or fully typed `safe` calls.
- [AsyncIteratorObject (SSE)](/docs/client/async-iterator-object): consume streamed events.
- [DynamicLink](/docs/client/dynamic-link): choose a link per call at runtime.

To add retries, batching, or timeouts, see [Plugins](/docs/plugins).
2 changes: 1 addition & 1 deletion apps/content/docs/contract-first.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Both sides now answer to the contract. The server cannot ship a response the con

## Next Steps

- Learn contracts in depth: [Procedure Contract](/docs/contract/procedure) and [Router Contract](/docs/contract/router)
- Learn contracts in depth: [Procedure Contract](/docs/contract/procedure), [Router Contract](/docs/contract/router), and the rest of the [Contract](/docs/contract) section
- Add middleware and context to implementations in [Contract Implementation](/docs/contract/implementation)
- Already have an OpenAPI spec? [Generate a contract from it](/docs/contract/generate-from-openapi)
- Keep type checking fast in large codebases with the [Contract Client Factory](/docs/contract/client-factory)
Expand Down
16 changes: 16 additions & 0 deletions apps/content/docs/contract/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Contract"
description: "Reference for oRPC contracts: describe procedures and routers without logic, implement them with type checking, generate them from OpenAPI, and scale clients."
seo:
title: "Contracts: Define, Implement, and Share an API"
sidebar:
hidden: true
---

A contract describes your API's input, output, and errors without any logic. The server implements it with full type checking, and clients use it without importing server code. For a walkthrough, start with [Contract-First](/docs/contract-first).

- [Procedure Contract](/docs/contract/procedure): define one procedure with the `oc` builder.
- [Router Contract](/docs/contract/router): group procedure contracts, or derive a contract from a router.
- [Contract Implementation](/docs/contract/implementation): implement a contract with `implement`.
- [Generate from OpenAPI](/docs/contract/generate-from-openapi): create a contract from an existing OpenAPI document.
- [Contract Client Factory](/docs/contract/client-factory): build clients per procedure to keep large codebases fast.
4 changes: 3 additions & 1 deletion apps/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,6 @@ orpc.planet.create
- Stream typed events over Server-Sent Events (SSE) with [AsyncIteratorObject](/docs/async-iterator-object)
- Expose the same router as a REST API with the [OpenAPI Handler](/docs/openapi/handler) and generate its [OpenAPI specification](/docs/openapi/specification)
- Define your API as a [contract first](/docs/contract-first), then let TypeScript enforce the implementation
- Integrate with your stack: [TanStack Query](/docs/integrations/tanstack-query), [SWR](/docs/integrations/swr), [Pinia Colada](/docs/integrations/pinia-colada), [Next.js](/docs/integrations/next), and [NestJS](/docs/integrations/nest)
- Integrate with your stack: [TanStack Query](/docs/integrations/tanstack-query), [SWR](/docs/integrations/swr), [Pinia Colada](/docs/integrations/pinia-colada), [Next.js](/docs/integrations/next), [NestJS](/docs/integrations/nest), and [more](/docs/integrations)
- Find ready-made [helpers](/docs/helpers) and [recipes](/docs/recipes) for cookies, rate limiting, testing, and more
- Coming from tRPC or oRPC v1? Follow a [migration guide](/docs/migrations)
28 changes: 28 additions & 0 deletions apps/content/docs/helpers/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "Helpers"
description: "Utilities that ship with oRPC for cookies, signing, encryption, base64url, and form data, plus packages for rate limiting, locks, and publish/subscribe."
seo:
title: "Helpers: Cookies, Signing, Rate Limits, and More"
sidebar:
hidden: true
---

Helpers handle common jobs inside procedures, middleware, and plugins.

## Built In

These come from `@orpc/server/helpers`, except Form Data, which comes from `@orpc/openapi/helpers`.

- [Cookie](/docs/helpers/cookie): set, read, and delete cookies on `Headers`.
- [Signing](/docs/helpers/signing): sign and verify data with HMAC-SHA256.
- [Encryption](/docs/helpers/encryption): encrypt and decrypt data with AES-GCM.
- [Base64Url](/docs/helpers/base64url): encode and decode URL-safe base64.
- [Form Data](/docs/helpers/form-data): parse nested form data and extract validation errors.

## With Storage Adapters

Each is a separate package with adapters for memory, Redis, Upstash, Bun, and Cloudflare.

- [Rate Limit](/docs/helpers/ratelimit): limit how often clients call a procedure.
- [Lock](/docs/helpers/lock): stop the same work from running concurrently (experimental).
- [Publisher](/docs/helpers/publisher): publish and subscribe to events, with resume support.
45 changes: 45 additions & 0 deletions apps/content/docs/integrations/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "Integrations"
description: "Use oRPC with the tools around it: Zod, Valibot, ArkType, TanStack Query, SWR, Next.js, NestJS, MCP, the AI SDK, OpenTelemetry, Better Auth, and more."
seo:
title: "Integrations: TanStack Query, Zod, MCP, and More"
sidebar:
hidden: true
---

Integrations connect oRPC to the libraries you already use. To run oRPC inside a framework or runtime, see [Adapters](/docs/adapters). For community packages, see [Ecosystem](/docs/ecosystem).

## Schema Validation

Any [Standard Schema](/docs/integrations/standard-schema) library works for validation as is. The [Zod](/docs/integrations/zod), [Valibot](/docs/integrations/valibot), and [ArkType](/docs/integrations/arktype) integrations add JSON Schema converters for OpenAPI generation and Smart Coercion.

## Data Fetching

- [TanStack Query](/docs/integrations/tanstack-query): query and mutation options for any TanStack Query framework.
- [SWR](/docs/integrations/swr): keys, fetchers, and mutators for React.
- [Pinia Colada](/docs/integrations/pinia-colada): query and mutation options for Vue.
- [Next.js](/docs/integrations/next): server functions, form actions, and React hooks.

## Frameworks and Libraries

- [NestJS](/docs/integrations/nest): implement oRPC contracts as NestJS controllers.
- [tRPC](/docs/integrations/trpc): convert tRPC routers into oRPC routers.
- [Effect](/docs/integrations/effect): write handlers with Effect and call clients as effects.
- [Better Auth](/docs/integrations/better-auth): Better Auth sessions in context and middleware.
- [Hibernation](/docs/integrations/hibernation): let servers sleep, as with Cloudflare's WebSocket Hibernation, without dropping connections.

## AI

- [MCP](/docs/integrations/mcp): expose procedures as tools for AI agents.
- [AI SDK](/docs/integrations/ai-sdk): stream AI SDK responses over oRPC and turn procedures into tools.
- [TanStack AI](/docs/integrations/tanstack-ai): stream TanStack AI chats over oRPC.

## Observability

- [OpenTelemetry](/docs/integrations/opentelemetry): distributed tracing across client and server.
- [Cloudflare Traces](/docs/integrations/cloudflare-traces): spans in Cloudflare Workers Traces.
- [Pino](/docs/integrations/pino) and [Evlog](/docs/integrations/evlog): structured request logging.

## Testing

- [MSW](/docs/integrations/msw): mock procedures at the network level with typed handlers.
11 changes: 11 additions & 0 deletions apps/content/docs/migrations/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Migrations"
description: "Guides for moving to oRPC v2: upgrade an existing oRPC v1 app, or migrate a tRPC app step by step or incrementally alongside your current routers."
seo:
title: "Migration Guides: From tRPC or oRPC v1"
sidebar:
hidden: true
---

- [Migrating from oRPC v1](/docs/migrations/from-v1): every change in v2, with v1 and v2 code side by side.
- [Migrating from tRPC](/docs/migrations/from-trpc): map tRPC concepts to oRPC and move step by step. To adopt oRPC gradually instead, [convert your tRPC routers](/docs/integrations/trpc).
34 changes: 34 additions & 0 deletions apps/content/docs/openapi/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "OpenAPI"
description: "Serve oRPC procedures as a REST API, generate an OpenAPI 3.x document from the same code, call it with a typed client, and render interactive API docs."
seo:
title: "OpenAPI: REST APIs and Generated Specs"
sidebar:
hidden: true
---

The same router can serve the [RPC protocol](/docs/rpc) for oRPC clients and a REST API for everyone else. Add routing metadata, serve it with the OpenAPI Handler, and generate the OpenAPI document from the same code.

## Define Routes

- [Routing](/docs/openapi/routing): set methods, paths, path parameters, and prefixes.
- [Input and Output Mapping](/docs/openapi/input-and-output-mapping): map params, query, headers, and body to input and output.
- [Bracket Notation](/docs/openapi/bracket-notation): encode nested data in query strings and form data.

## Serve

- [OpenAPI Handler](/docs/openapi/handler): expose procedures as HTTP endpoints on any HTTP [adapter](/docs/adapters).
- [OpenAPI Serializer](/docs/openapi/serializer): how `Date`, `BigInt`, and files become JSON-friendly.

## Document

- [OpenAPI Specification](/docs/openapi/specification): generate an OpenAPI 3.0, 3.1, or 3.2 document.
- [Scalar (Swagger)](/docs/openapi/scalar): serve an interactive API reference, or use the [OpenAPI Reference Plugin](/docs/plugins/openapi-reference).

## Call

- [OpenAPI Link](/docs/openapi/link): a typed client for any OpenAPI-compliant server.
- [Expanding Type Support for OpenAPI Link](/docs/openapi/expanding-type-support-for-link): restore `Date`, `bigint`, and other native types on the client.
- [OpenAPI Link Without Runtime Imports](/docs/openapi/link-without-runtime-imports): embed the contract at build time.

To go the other way, [generate a contract from OpenAPI](/docs/contract/generate-from-openapi).
50 changes: 50 additions & 0 deletions apps/content/docs/plugins/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "Plugins"
description: "Add CORS, batching, retries, compression, timeouts, and validation to oRPC with built-in plugins for handlers on the server and links on the client."
seo:
title: "Plugins: CORS, Batching, Retries, and More"
sidebar:
hidden: true
---

Plugins add reusable behavior through the `plugins` option. Handler plugins (`...HandlerPlugin`) run on the server, in a handler such as the [RPC Handler](/docs/rpc/handler). Link plugins (`...LinkPlugin`) run on the [client](/docs/client), in a link such as the [RPC Link](/docs/rpc/link). Some features need both.

## Security

- [CORS](/docs/plugins/cors) (server): set allowed origins, methods, and headers.
- [GET Method CSRF Protection](/docs/plugins/get-method-csrf-protection) (server): make `GET` procedures as safe as `POST`.
- [Request Limit](/docs/plugins/request-limit) (server): cap request body size.

## Performance

- [Batch](/docs/plugins/batch) (both): send several calls in one request.
- [Batch Response Compression](/docs/plugins/batch-response-compression) (server): compress batch responses.
- [Dedupe](/docs/plugins/dedupe) (client): merge identical in-flight requests.
- [Request Compression](/docs/plugins/request-compression) (both): compress request bodies.
- [Response Compression](/docs/plugins/response-compression) (both): compress response bodies.

## Reliability

- [Retry](/docs/plugins/retry) (client): retry failed calls.
- [Retry After](/docs/plugins/retry-after) (client): retry when the server sends `Retry-After`.
- [Timeout](/docs/plugins/timeout) (both): abort calls that take too long.
- [Signal Sync](/docs/plugins/signal-sync) (server): keep the request signal and streaming responses in sync.

## Headers and HTTP

- [Request Headers](/docs/plugins/request-headers) (server): read headers through `context.reqHeaders`.
- [Response Headers](/docs/plugins/response-headers) (server): set headers and cookies through `context.resHeaders`.
- [Method Override](/docs/plugins/method-override) (server): let HTML forms call `PUT`, `PATCH`, and `DELETE`.
- [Rethrow](/docs/plugins/rethrow) (server): pass errors on to your framework's error handling.

## Validation and Types

- [Request Validation](/docs/plugins/request-validation) (client): validate input before sending.
- [Response Validation](/docs/plugins/response-validation) (client): validate responses against the contract.
- [Smart Coercion](/docs/plugins/smart-coercion) (both): coerce values to match your schemas.

## Files and Docs

- [Static File](/docs/plugins/static-file) (server): serve static files next to your procedures.
- [Tmp File Upload](/docs/plugins/tmp-file-upload) (server): stream large uploads to temporary files.
- [OpenAPI Reference](/docs/plugins/openapi-reference) (server): serve Scalar or Swagger UI and the OpenAPI document.
19 changes: 19 additions & 0 deletions apps/content/docs/recipes/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Recipes"
description: "Practical oRPC recipes for testing and mocking, validation, monorepos, publishing a typed client to npm, faster SSR, and fixing common TypeScript errors."
seo:
title: "Recipes: Testing, Monorepos, SSR, and More"
sidebar:
hidden: true
---

Short guides for common tasks and problems.

- [Testing and Mocking](/docs/recipes/testing-and-mocking): test procedures directly and mock them.
- [Validation Customization](/docs/recipes/validation-customization): turn off validation or shape validation errors.
- [Monorepo Setup](/docs/recipes/monorepo-setup): keep types end to end across packages.
- [Publish Client to NPM](/docs/recipes/publish-client-to-npm): ship your client as a typed SDK.
- [Optimizing SSR](/docs/recipes/optimizing-ssr): skip HTTP when rendering on the server.
- [Dedupe Middleware](/docs/recipes/dedupe-middleware): avoid repeating expensive middleware work.
- [No Throw Literal](/docs/recipes/no-throw-literal): why oRPC expects `Error` instances.
- [Exceeds the Maximum Length Problem](/docs/recipes/exceeds-the-maximum-length-problem): fix the error for very large router types.
15 changes: 15 additions & 0 deletions apps/content/docs/rpc/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "RPC"
description: "How oRPC's RPC protocol connects oRPC clients and servers, with a serializer that keeps Date, BigInt, Map, Set, files, and streams intact across the wire."
seo:
title: "RPC: Protocol, Serializer, Handler, and Link"
sidebar:
hidden: true
---

RPC is oRPC's default protocol between its own clients and servers. It works over HTTP, WebSocket, and message ports. To serve a REST API from the same router, see [OpenAPI](/docs/openapi).

- [RPC Protocol](/docs/rpc/protocol): how calls are routed, encoded, and answered.
- [RPC Serializer](/docs/rpc/serializer): the types supported beyond JSON, and how to add your own.
- [RPC Handler](/docs/rpc/handler): serve procedures on the server.
- [RPC Link](/docs/rpc/link): call an RPC Handler from a client.
Loading