Plugins
Add CORS, batching, retries, compression, timeouts, and validation to oRPC with built-in plugins for handlers on the server and links on the client.
Plugins add reusable behavior through the plugins option. Handler plugins (...HandlerPlugin) run on the server, in a handler such as the RPC Handler. Link plugins (...LinkPlugin) run on the client, in a link such as the RPC Link. Some features need both.
Security
- CORS (server): set allowed origins, methods, and headers.
- GET Method CSRF Protection (server): make
GETprocedures as safe asPOST. - Request Limit (server): cap request body size.
Performance
- Batch (both): send several calls in one request.
- Batch Response Compression (server): compress batch responses.
- Dedupe (client): merge identical in-flight requests.
- Request Compression (both): compress request bodies.
- Response Compression (both): compress response bodies.
Reliability
- Retry (client): retry failed calls.
- Retry After (client): retry when the server sends
Retry-After. - Timeout (both): abort calls that take too long.
- Signal Sync (server): keep the request signal and streaming responses in sync.
Headers and HTTP
- Request Headers (server): read headers through
context.reqHeaders. - Response Headers (server): set headers and cookies through
context.resHeaders. - Method Override (server): let HTML forms call
PUT,PATCH, andDELETE. - Rethrow (server): pass errors on to your framework’s error handling.
Validation and Types
- Request Validation (client): validate input before sending.
- Response Validation (client): validate responses against the contract.
- Smart Coercion (both): coerce values to match your schemas.
Files and Docs
- Static File (server): serve static files next to your procedures.
- Tmp File Upload (server): stream large uploads to temporary files.
- OpenAPI Reference (server): serve Scalar or Swagger UI and the OpenAPI document.