Favicon of Effect

Effect

Effect is a TypeScript library for building production-grade apps with typed errors, dependency injection, concurrency, and schema validation.

Effect website screenshot
Effect GitHub repository preview

Effect is a TypeScript library for building production applications that need to handle failure, concurrency, and dependencies in a predictable way. It's aimed at TypeScript developers who are tired of ad-hoc error handling, manual dependency wiring, and callback-based async code, and who want a type-safe alternative that scales across a monorepo of integration packages.

The core effect package ships with a wide set of integration packages for platforms (Node.js, Bun, Deno, browser), SQL clients (Postgres, MySQL, SQLite, ClickHouse, D1, and more), AI providers (OpenAI, Anthropic, Cloudflare, OpenRouter), and framework bindings (React, Vue, SolidJS). All packages in the monorepo are versioned and released together.

Key features

  • Typed errors: failures are tracked in the type system instead of being thrown and caught blindly, so you know what can go wrong at compile time.
  • Dependency injection: a built-in system for wiring services and dependencies without external DI frameworks.
  • Structured concurrency: fibers, scheduling, and cancellation are managed explicitly, avoiding the usual pitfalls of raw promises and async/await.
  • Unified schema validation: one schema system for parsing, validating, and encoding data across your application.
  • Observability: built-in tracing with OpenTelemetry integration for production debugging.
  • Platform abstraction: shared APIs across Node.js, Bun, Deno, and the browser, so platform-specific code stays isolated.
  • SQL clients: typed clients for Postgres, MySQL, SQL Server, ClickHouse, SQLite (multiple runtimes), and Cloudflare D1/Durable Objects.
  • AI module providers: packages for OpenAI, Anthropic, Cloudflare, and OpenRouter, plus an OpenAI-compatible adapter.
  • Testing helpers: @effect/vitest for writing tests against Effect code, plus @effect/doctest for running JSDoc examples as tests.
  • Code generation tools: generate Effect code from OpenAPI or GraphQL specs, and generate API docs with @effect/docgen.

Ideal use cases

Effect fits teams building backend services, CLIs, or data pipelines in TypeScript where error handling and concurrency bugs have real production cost, for example a service that talks to multiple databases and external APIs and needs consistent retry, timeout, and cancellation behavior. It also suits teams that want a single schema definition reused for validation, parsing, and serialization instead of maintaining separate libraries for each.

It's a good match if you're already comfortable with TypeScript's type system and want compile-time guarantees around failure modes, not just runtime checks. Teams adopting Effect across a monorepo benefit from the ready-made platform and SQL integration packages rather than writing that glue code themselves.

It's less of a fit for small scripts or prototypes where the learning curve of a new programming model (fibers, typed errors, the Effect type) outweighs the benefit. If your team isn't willing to invest in learning functional-style composition, or you need a minimal dependency footprint for a tiny project, plain async/await and try/catch will likely be faster to ship with. Projects stuck on older TypeScript versions or without strict mode enabled will also need to adjust their setup first.

Installation

Install the core package with npm:

npm install effect

Before adopting it, check the requirements:

  • TypeScript 5.9 or newer (TypeScript 7 recommended for best performance and tooling compatibility).
  • Node.js 18 or newer to run Effect on Node.js; some integration packages need newer runtimes (for example, @effect/sql-sqlite-node requires Node.js 22.16 or newer).
  • The strict flag enabled in tsconfig.json.

Integration packages (platform, SQL, AI, framework bindings) are installed separately as needed, for example @effect/platform-node or @effect/sql-pg, and are versioned in sync with the core package.

If you're upgrading from Effect 3.x, follow the migration guide in the repository (MIGRATION.md); Effect 4.x is a long-term support release with multi-year bug and security fix guarantees. The v3 source lives on the v3 branch for anyone still targeting that line.

Frequently asked questions

Share:

Stars
17.3K
Forks
869
Last commit
5 hours ago
Repository age
7 years
License
MIT
Self-hosted
No
Activity score
80/100
View Repository
Ad
Favicon

 

  
 

Similar to Effect

Favicon

 

  
 
Favicon

 

  
 
Favicon