Skip to content

Effect v4 Documentation

The missing standard library for TypeScript. Build robust, composable, and type-safe applications — from a quick script to a distributed system.

Effect lets you describe programs as composable, type-safe values. Errors and dependencies are tracked in the type system, concurrency is structured, and resources are released automatically.

import { Effect, Schema } from "effect"
// Errors are values, defined as data
class UserNotFound extends Schema.TaggedErrorClass<UserNotFound>()(
"UserNotFound",
{ id: Schema.Number }
) {}
// `Effect.fn` defines a function that returns an Effect, with a built-in span
const getUser = Effect.fn("getUser")(function* (id: number) {
yield* Effect.log(`looking up user ${id}`)
if (id <= 0) {
// Failures are typed — this shows up in the Effect's error channel
return yield* new UserNotFound({ id })
}
return { id, name: "Ada" }
})
const program = getUser(1).pipe(
// Recover from the typed error without losing type-safety
Effect.catchTag("UserNotFound", (e) =>
Effect.succeed({ id: e.id, name: "anonymous" })
)
)

Effect v4 ships batteries-included modules for real-world systems — all designed to compose.

HTTP APIs

Define schema-first, type-safe HTTP APIs with runtime validation, typed clients, and OpenAPI docs from one definition. See HTTP API.

CLIs

Build command-line apps with typed arguments, flags, and subcommands. See CLI.

AI

A provider-agnostic interface for language models — generate text, decode structured objects, stream responses, and define tools. See AI.

Distributed systems

Model stateful services as entities and distribute them across machines with the cluster modules. See Cluster.