Skip to main content
Use .provide(tag, provider) when a service depends on the current request. Providers can be generator callbacks, Effect.fn(...) callbacks, or functions that return an Effect. Common examples:
  • current user
  • request ID
  • tenant ID
  • authorization scope
  • locale

Provide from context

current-user.ts

Effect-returning providers

Use an Effect-returning provider when the service construction is already expressed as an Effect, or when you want to keep a named Effect.fn(...) span.
effect-provider.ts

Provide from input

Providers can also use parsed input.
tenant.ts

Optional providers

Use .provideOptional(...) when a service may be absent. The provider returns an Option and does not satisfy required service access. Optional providers support the same generator and Effect-returning callback shapes.
optional-current-user.ts
Optional providers are useful for anonymous-or-authenticated routes. If a handler requires the service, use .provide(...) instead.

Next step

Add client-visible failures with Typed errors.
Last modified on June 15, 2026