OpenRPC Adapters
The HTTP and WebSocket adapters that run OpenRPC Handler and OpenRPC Link for JSON-RPC 2.0, and where to import each one.
OpenRPC runs over HTTP and WebSocket. Pick the adapter for your transport, then import OpenRPC Handler or OpenRPC Link from it. For message ports, use RPC.
Server Adapters
| Adapter | Import OpenRPCHandler from |
|---|---|
| Fetch API | @orpc/openrpc/fetch |
| Node HTTP | @orpc/openrpc/node |
| Fastify | @orpc/openrpc/fastify |
| AWS Lambda | @orpc/openrpc/aws-lambda |
| WebSocket | @orpc/openrpc/websocket |
The HTTP adapters answer POST requests to the prefix path itself, such as /rpc, so mount the handler on a route that matches it. In Fastify, use app.all('/rpc', ...): /rpc/* does not match /rpc, and a POST-only route would keep CORS preflight requests from reaching the handler. The WebSocket adapter answers each message on its socket, also from crossws hooks, see OpenRPC Handler over WebSocket.
Client Adapters
| Adapter | Import OpenRPCLink from |
Calls |
|---|---|---|
| Fetch API | @orpc/openrpc/fetch |
Any HTTP server adapter |
| WebSocket | @orpc/openrpc/websocket |
WebSocket server adapter |
Both also call any other JSON-RPC 2.0 server over the same transport.
Frameworks and Platforms
Every framework and platform adapter built on the Fetch API or Node HTTP also serves OpenRPC, such as Next.js, Hono, Express.js, and Cloudflare Workers. Where an example uses RPCHandler, swap in OpenRPCHandler from the matching import above. See Adapters for the full list.