Skip to main content
Effect is a powerful TypeScript framework designed to help developers build robust, scalable, and maintainable applications. It provides a unified approach to handling errors, managing resources, controlling concurrency, and structuring dependencies.

Why Effect?

Effect transforms how you write TypeScript applications by providing a complete toolkit for managing side effects and complex application logic:

Type-Safe Error Handling

Track errors at the type level and handle them explicitly, eliminating unexpected runtime failures.

Structured Concurrency

Built-in fiber-based concurrency with automatic resource cleanup and interruption handling.

Dependency Injection

Type-safe dependency management through Context and Layer, making testing and composition effortless.

Resource Safety

Automatic resource acquisition and release with Scope, ensuring no leaks even on failures.

Your First Effect Program

Here’s a simple example showcasing Effect’s generator-based syntax with built-in error handling:
import { Effect, Console } from "effect"

const program = Effect.gen(function* () {
  const user = yield* fetchUser(123)
  const posts = yield* fetchUserPosts(user.id)
  yield* Console.log(`User ${user.name} has ${posts.length} posts`)
  return posts
})

const fetchUser = (id: number) =>
  Effect.tryPromise({
    try: () => fetch(`/api/users/${id}`).then(r => r.json()),
    catch: () => new Error("Failed to fetch user")
  })

const fetchUserPosts = (userId: number) =>
  Effect.tryPromise({
    try: () => fetch(`/api/users/${userId}/posts`).then(r => r.json()),
    catch: () => new Error("Failed to fetch posts")
  })

// Run the program
Effect.runPromise(program).then(console.log)
Notice how errors are tracked in the type system and async operations compose naturally using yield*.

Core Concepts

The Effect<A, E, R> type represents a computation that:
  • Succeeds with a value of type A
  • Fails with an error of type E
  • Requires a context of type R
This tri-parameter approach gives you complete visibility into what your program does, what can go wrong, and what it needs to run.

Get Started

Quickstart

Build your first Effect application in 5 minutes

Installation

Complete setup guide with TypeScript configuration

What You’ll Learn

Effect is more than a library—it’s a comprehensive approach to building TypeScript applications:
  • Error Management: Never lose track of errors with type-level error tracking
  • Concurrency Primitives: Fibers, queues, semaphores, and more for safe concurrent programming
  • Resource Management: Automatic cleanup with acquireRelease and Scope
  • Dependency Injection: Context and Layer for modular, testable code
  • Observability: Built-in tracing, metrics, and structured logging
  • Data Validation: Schema for runtime type validation and transformation
Effect requires TypeScript 5.4 or newer with strict mode enabled. See the Installation guide for complete setup instructions.

Build docs developers (and LLMs) love