.provide(tag, fn) 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
Provide from input
Providers can also use parsed input.tenant.ts
Provider callback shapes
Request-scoped providers can be generator callbacks,Effect.fn(...) callbacks, or functions that return an Effect.
provider-shapes.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.