# Welcome to Effect

Effect is a TypeScript library for building production-grade software: typed
error handling, structured concurrency, resource safety, and observability,
all from one composable core.

## Why Effect?

### Typed data, untyped programs

TypeScript is excellent at describing your data, but it says almost nothing about your programs: a function's signature doesn't tell you what can fail, what dependencies it needs, or whether it can be safely retried, timed out, or interrupted. As applications grow, teams end up hand-rolling those guarantees with ad-hoc try/catch, unstructured promises, and libraries that don't compose.

### Programs as values

Effect closes that gap with a single building block: the `Effect` type, a value that fully describes a program, including its success value, its possible errors, and its requirements. Because programs are values, they compose: retries, timeouts, concurrency, resource handling, and tracing are operators you apply, not architectures you rebuild.

<div class="not-prose my-8 overflow-hidden rounded-md border border-zinc-200 dark:border-zinc-800">
  <div class="border-b border-zinc-200 bg-zinc-50 px-4 py-3 font-mono text-xs font-medium uppercase tracking-wider text-zinc-700 dark:border-zinc-800 dark:bg-zinc-900/40 dark:text-zinc-300">
    Out of the box
  </div>
  <dl class="grid grid-cols-1 gap-px bg-zinc-200 sm:grid-cols-2 dark:bg-zinc-800">
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Typed errors
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Failures live in the signature and are handled like data.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Retries and scheduling
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Backoff policies you compose instead of loops you write.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Structured concurrency
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Bounded parallel work that cleans up after itself.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Resource safety
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Acquisition and release are guaranteed, even when things fail.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Dependency injection
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Services wired through the type system, trivial to swap in tests.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Observability
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Tracing, metrics, and structured logging built into the runtime.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Streaming
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Backpressured streams that use the same operators as everything else.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Schema validation
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Parse and transform data with types that match reality.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        Configuration
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        Typed config from the environment, validated at startup, secrets
        redacted.
      </dd>
    </div>
    <div class="bg-white px-4 py-3 dark:bg-zinc-950">
      <dt class="text-sm font-semibold text-zinc-900 dark:text-white">
        A consistent ecosystem
      </dt>
      <dd class="mt-1 text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
        HTTP, SQL, CLI, AI, and platform packages built on the same core.
      </dd>
    </div>
  </dl>
</div>

### Built for the AI era

The AI era raises the stakes. When coding agents write a growing share of your software, the bottleneck moves from writing code to trusting it. Effect makes a program's failure modes, dependencies, and lifecycle visible to the compiler, turning runtime surprises into precise feedback an agent can act on. And when the thing you are building is itself an AI application, flaky providers, retries, streaming, and rate limits are exactly the problems Effect solves out of the box.

## Your Learning Path

Effect rewards learning in order: each step builds on the one before it. Following this spine takes most developers a few focused days; everything else branches off from it.

<ol class="not-prose my-8 list-none divide-y divide-zinc-200 pl-0 dark:divide-zinc-800">
  <li class="pl-0">
    <a
      href="/docs/v4/getting-started/the-effect-type"
      class="group flex items-baseline gap-4 py-5 no-underline sm:gap-6"
    >
      <span
        class="font-mono text-sm font-medium text-zinc-400 dark:text-zinc-500"
        aria-hidden="true"
      >
        01
      </span>
      <span class="flex-1">
        <span class="text-base font-semibold text-zinc-900 underline-offset-4 group-hover:underline dark:text-white">
          Understand the core idea
        </span>
        <span class="mt-1 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
          An Effect is a value that describes a program: what it produces, how
          it can fail, and what it needs to run. Everything else builds on this
          one type.
        </span>
      </span>
      <span
        class="hidden shrink-0 text-sm font-medium text-zinc-500 transition-colors group-hover:text-zinc-900 md:block dark:text-zinc-400 dark:group-hover:text-white"
        aria-hidden="true"
      >
        The Effect Type →
      </span>
    </a>
  </li>
  <li class="pl-0">
    <a
      href="/docs/v4/getting-started/installation"
      class="group flex items-baseline gap-4 py-5 no-underline sm:gap-6"
    >
      <span
        class="font-mono text-sm font-medium text-zinc-400 dark:text-zinc-500"
        aria-hidden="true"
      >
        02
      </span>
      <span class="flex-1">
        <span class="text-base font-semibold text-zinc-900 underline-offset-4 group-hover:underline dark:text-white">
          Set up your project
        </span>
        <span class="mt-1 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
          Install the library and configure TypeScript. Effect is a single
          dependency with zero required tooling.
        </span>
      </span>
      <span
        class="hidden shrink-0 text-sm font-medium text-zinc-500 transition-colors group-hover:text-zinc-900 md:block dark:text-zinc-400 dark:group-hover:text-white"
        aria-hidden="true"
      >
        Installation →
      </span>
    </a>
  </li>
  <li class="pl-0">
    <a
      href="/docs/v4/getting-started/creating-effects"
      class="group flex items-baseline gap-4 py-5 no-underline sm:gap-6"
    >
      <span
        class="font-mono text-sm font-medium text-zinc-400 dark:text-zinc-500"
        aria-hidden="true"
      >
        03
      </span>
      <span class="flex-1">
        <span class="text-base font-semibold text-zinc-900 underline-offset-4 group-hover:underline dark:text-white">
          Write your first program
        </span>
        <span class="mt-1 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
          Create effects, compose them with generators, and run them at the edge
          of your app.
        </span>
      </span>
      <span
        class="hidden shrink-0 text-sm font-medium text-zinc-500 transition-colors group-hover:text-zinc-900 md:block dark:text-zinc-400 dark:group-hover:text-white"
        aria-hidden="true"
      >
        Creating Effects →
      </span>
    </a>
  </li>
  <li class="pl-0">
    <a
      href="/docs/v4/error-management/two-error-types"
      class="group flex items-baseline gap-4 py-5 no-underline sm:gap-6"
    >
      <span
        class="font-mono text-sm font-medium text-zinc-400 dark:text-zinc-500"
        aria-hidden="true"
      >
        04
      </span>
      <span class="flex-1">
        <span class="text-base font-semibold text-zinc-900 underline-offset-4 group-hover:underline dark:text-white">
          Handle errors the Effect way
        </span>
        <span class="mt-1 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
          Errors are typed values, not surprises. Learn expected vs unexpected
          failures, fallbacks, and retries.
        </span>
      </span>
      <span
        class="hidden shrink-0 text-sm font-medium text-zinc-500 transition-colors group-hover:text-zinc-900 md:block dark:text-zinc-400 dark:group-hover:text-white"
        aria-hidden="true"
      >
        Two Types of Errors →
      </span>
    </a>
  </li>
  <li class="pl-0">
    <a
      href="/docs/v4/concurrency/basic-concurrency"
      class="group flex items-baseline gap-4 py-5 no-underline sm:gap-6"
    >
      <span
        class="font-mono text-sm font-medium text-zinc-400 dark:text-zinc-500"
        aria-hidden="true"
      >
        05
      </span>
      <span class="flex-1">
        <span class="text-base font-semibold text-zinc-900 underline-offset-4 group-hover:underline dark:text-white">
          Go concurrent
        </span>
        <span class="mt-1 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
          Run effects in parallel with bounded concurrency, race them, and let
          structured concurrency clean up after you.
        </span>
      </span>
      <span
        class="hidden shrink-0 text-sm font-medium text-zinc-500 transition-colors group-hover:text-zinc-900 md:block dark:text-zinc-400 dark:group-hover:text-white"
        aria-hidden="true"
      >
        Basic Concurrency →
      </span>
    </a>
  </li>
</ol>

Here's the kind of program you'll be writing within the first hour:

```ts
import { Effect } from "effect"

const program = Effect.gen(function* () {
  const name = yield* Effect.succeed("world")
  yield* Effect.log("Hello, " + name + "!")
})

Effect.runPromise(program)
```

## Keep Going

<div class="not-prose my-8 grid grid-cols-1 gap-4 md:grid-cols-3">
  <a
    href="/docs/v4/getting-started"
    class="group rounded-lg border border-zinc-200 bg-white p-6 no-underline transition-colors hover:border-zinc-300 dark:border-zinc-800 dark:bg-zinc-900/50 dark:hover:border-zinc-700"
  >
    <span class="block text-base font-semibold text-zinc-900 dark:text-white">
      Guides{" "}
      <span
        class="ml-1 inline-block transition-transform group-hover:translate-x-0.5"
        aria-hidden="true"
      >
        →
      </span>
    </span>
    <span class="mt-2 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
      The in-depth documentation: every topic from pipelines to PubSub,
      structured to read in order or dip into.
    </span>
  </a>
  <a
    href="/docs/v4/api"
    class="group rounded-lg border border-zinc-200 bg-white p-6 no-underline transition-colors hover:border-zinc-300 dark:border-zinc-800 dark:bg-zinc-900/50 dark:hover:border-zinc-700"
  >
    <span class="block text-base font-semibold text-zinc-900 dark:text-white">
      Reference{" "}
      <span
        class="ml-1 inline-block transition-transform group-hover:translate-x-0.5"
        aria-hidden="true"
      >
        →
      </span>
    </span>
    <span class="mt-2 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
      The complete API reference for every Effect module, versioned per release.
    </span>
  </a>
  <a
    href="/play"
    class="group rounded-lg border border-zinc-200 bg-white p-6 no-underline transition-colors hover:border-zinc-300 dark:border-zinc-800 dark:bg-zinc-900/50 dark:hover:border-zinc-700"
  >
    <span class="block text-base font-semibold text-zinc-900 dark:text-white">
      Playground{" "}
      <span
        class="ml-1 inline-block transition-transform group-hover:translate-x-0.5"
        aria-hidden="true"
      >
        →
      </span>
    </span>
    <span class="mt-2 block text-sm leading-relaxed text-zinc-700 dark:text-zinc-300">
      Run Effect in your browser with a full editor, no local setup needed.
      Ideal as a second tab while you learn.
    </span>
  </a>
</div>

## Join our Community

The Effect community lives on [Discord](https://discord.gg/effect-ts): the core team and experienced users are there daily, and no question goes unanswered.
