A procedure is the fundamental building block in oRPC. It represents one callable API operation: a function that accepts validated input and returns validated output. You build procedures using theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/middleapi/orpc/llms.txt
Use this file to discover all available pages before exploring further.
os builder from @orpc/server.
Basic procedure
The simplest procedure has no input schema — it just defines a handler:Defining input and output
Chain.input() and .output() to add Zod (or any Standard Schema-compatible) validators:
options object with the following properties:
| Property | Description |
|---|---|
input | Validated and parsed input, typed from your input schema |
context | Request-scoped data passed from middleware and the server handler |
errors | Type-safe error constructors defined with .errors() |
path | The procedure’s path in the router hierarchy |
procedure | Reference to the current procedure |
signal | AbortSignal from the request |
lastEventId | Last event ID for SSE reconnections |
Input-only procedure
You can omit.output() — oRPC will infer the return type from the handler:
The builder chain
Theos builder supports a fluent chain. You can call the steps in this order:
.input() and .output() are optional. If you omit them, the procedure accepts any input and returns the inferred handler output type.Adding middleware to a procedure
You can attach middleware directly to a procedure with.use(). Middleware runs before the handler and can modify context or short-circuit the call:
Reusing procedures
Because procedures are plain objects, you can store them in variables, import them across files, and compose them into routers freely. See Routers for how to group procedures together.Server actions
ADecoratedProcedure can be made callable as a React Server Action with .actionable():
