Skip to main content

Overview

The oRPC integration provides Effect-first handlers for oRPC procedures. Build type-safe RPC APIs where handlers can access Effect services and use structured concurrency.

Installation

Exports

createHandler

Create an oRPC procedure with an Effect-based handler.

Signature

Parameters

SimpleBuilder
required
An oRPC procedure builder (created with os.input(), os.output(), etc.). The builder must have a .handler() method.
(opt: OPT) => Effect.Effect<OUTPUT, unknown, R>
required
Effect-based handler function. Receives the procedure’s input and context, returns an Effect.The opt parameter contains:
  • input - The validated input data
  • context - Request context (user, session, etc.)
  • Other oRPC metadata

Returns

Returns an Effect that yields the fully implemented oRPC procedure. The Effect requires any services (R) that the handler depends on.

Basic Usage

Simple Procedure

With Output Schema

Using Services

Access Effect services within handlers:

Working with Contracts

Use oRPC contracts for shared client/server types:

Context

Access request context (user, session, etc.):

FfOrpcCtx

Use FfOrpcCtx to provide custom Effect runtime when calling procedures:

Creating FfOrpcCtx

Using FfOrpcCtx

If no FfOrpcCtx is provided, handlers fall back to using runPromiseUnwrapped with the current runtime.

Error Handling

Effect Errors

Effect errors are automatically converted to thrown errors in the RPC response:

Handling Errors

Complete Example

See Also