Skip to main content
Effect is a TypeScript library for programs with typed errors, managed dependencies, retries, cancellation, and safe resource use. It makes these needs visible in your types and gives you tools to combine them. Forst already gives you typed backend functions and generated clients. Effect mode carries those types into Node. Each generated call has typed Forst failures and declares the service it needs. This makes calls easier to provide, retry, cancel, and replace in tests.
Install @forst/cli first. Add a postinstall script that runs forst generate .. Run generate once before you import @forst/gen. Details are on the Installation page.
Install effect, enable Effect mode, then regenerate:
Without Effect.provide, TypeScript reports an unsatisfied R channel. That is expected. Provide ForstClientLive (or a custom layer) before you run the program. Full generate fields live on the CLI reference.

Two separate points

Promise mode keeps structural compatibility. Default clients inline a small tagged-error helper. Every invoke failure carries a readonly _tag that matches the Data.TaggedError contract, so Effect.catchTag works without adding effect as a runtime dependency. Effect mode uses real Effect errors. With generate.effect: true, invoke, domain, and harness errors extend Data.TaggedError from the effect peer. Equal.equals and other Effect APIs work on error values. Function returns become Effect values with a typed error channel.

What changes

Both modes import the package handle (for example $auth from @forst/gen/auth) and call $auth.VerifyPassword(...).

Errors

Catch by tag in either mode:
See Call Forst from Node for the full failure guide.

Wiring

Set FORST_BASE_URL in production. The client never spawns a server when NODE_ENV is production.

Testing

Same three levels as Testing, expressed as layers. One method with Layer.mock:
An unstubbed method fails loudly (UnimplementedError). That is why Effect mode requires effect >=3.17.0. Whole client with ForstTestLayer:
Handlers may return a value, a Promise, or an Effect. Wire level with a fake transport, when you need to assert payloads or simulate a specific failure. Provide a mock ForstTransport under the real package services. See Testing for the Promise mode equivalents. Real invoke server with the test trio that mirrors ForstClientLive / ForstClientLayer / makeForstClientRuntime. Install optional @forst/cli, then:
For Vitest or Jest hooks, use makeForstTestServer() and call dispose() in afterAll. See Testing.

Requirements

  • Install effect in your app (>=3.17.0).
  • Set "generate": { "effect": true } in ftconfig.json.
  • Run npx forst generate . after changing that flag.
If the resolved effect version is missing or too old, generate fails and names the version it found, the floor (>=3.17.0), and why.

Call Forst from Node

Promise mode calls, tagged errors, and .safe().

Testing

withForstTestScope for Promise mode.

Installation

@forst/cli, postinstall, and first generate.

Generate a TypeScript client

Subpaths and @forst/gen imports.

CLI reference

Full generate configuration table.