better-effect
Reference

Packages and integrations

Choose the right better-effect package and keep ownership explicit.

The monorepo is split into small packages. The core stays framework-neutral; integrations and storage drivers are optional and are installed only when an application uses them. Every integration follows the same rule: describe providers with Layers, capture only non-owning capabilities, and keep resource ownership at the composition root.

Core and application boundaries

PackageUse it forPublic entry points
better-effectEffect, Layer, Runtime, Scope, Web boundaries and standard services., /web, /bun, /hono, /next, /node, /opentelemetry
better-effect-httpTyped Fetch requests, status unions, retries, auth recovery and streaming., /endpoints, /testing, /opentelemetry
better-effect-schemaStandard Schema classes, codecs, tagged classes and typed failures., /zod, /valibot, /arktype
better-effect-better-authBetter Auth Services, hooks, plugin middleware and current sessions., /hooks, /hono
better-effect-kyselyKysely query terminals, transactions and explicit database ownership.

The HTTP client consumes Standard Schema values directly. It does not install a schema provider. Use a better-effect-schema adapter only when an application needs provider-specific class derivations or helpers.

Durable queues and storage

PackageUse it forOwnership and compatibility
better-effect-mqQueues, immutable Jobs, producer Programs, Layer-first Workers, optional extensions and testingStorage-neutral; no database connection or driver
better-effect-mq-outboxPrepared enqueue records, routes, post-commit stores and publishersStorage-neutral; delivery is at-least-once
better-effect-mq-postgresPostgreSQL JobStore, optional events, schedules, flows and outboxCaller-owned or config-created PostgreSQL pool
better-effect-mq-redisRedis/Valkey JobStore, optional events, schedules and flowsCaller-owned clients or adapter-created connections
better-effect-mq-mongodbMongoDB JobStore, optional events, schedules, flows and outboxRequires transaction-capable MongoDB deployment
better-effect-mq-sqliteEmbedded SQLite JobStore, optional events, schedules, flows and outboxOne writer; migration and database ownership are explicit
better-effect-mq-mysqlMySQL/InnoDB JobStore, optional events, schedules, flows and outboxMySQL 8/InnoDB; migration and pool ownership are explicit

Read the MQ guide for the storage-neutral contracts, the adapter guides for durable providers, and the outbox guide for post-commit publishing. Driver-specific migrations, connection options and deployment requirements live in each adapter's package README.

Choosing an ownership model

  • Use Layer.succeed for a caller-owned value that a Runtime must not dispose.
  • Use a scoped Layer when the Layer creates the resource and should release it with the Runtime root Scope.
  • Use an integration's borrowed or caller-owned form when another Layer owns a shared pool, client or Kysely instance.
  • Use NodeRuntime.launch or NodeRuntime.runMain for a process-owned server root. Use NextEffect.managed only when Next owns the process lifecycle.
  • Use Worker.service(...).layer(...) and OutboxPublisher.service(...).layer(...) for supervised background components; do not start detached loops from an application callback.

Optional peers

The core package does not require Hono, Bun, Next.js, Better Auth, Kysely, OpenTelemetry, database drivers or schema providers. Optional peers belong to the subpath or package that uses them. This keeps a generic consumer small and lets package tarball tests prove that unused integrations are not loaded.

For removed Runtime-first APIs and the exact replacement for each integration, see Layer-first migration.

On this page