A frontend library for Effect. Each component is an Elm Architecture program of its own, and you build an app by composing components. A component owns its Model (defined with Schema along with props, messages, and events), handles its messages with a pure update, and renders its Model with view. Side effects run as Commands and Subscriptions managed by the runtime, data fetching and caching come from Query, and services are provided with Layers. The core is host-agnostic: @effect/ui/html renders to the DOM, and @effect/ui-opentui to terminals with OpenTUI.
The packages are experimental and not yet on npm: install them from snapshots.
- ui.effect.website: overview and interactive walkthrough
LLMS.md: the guide and worked examples, generated fromai-docs/
import { UiSchema } from "@effect/ui"
import { BrowserHost, Html } from "@effect/ui/html"
import { Effect, Layer, Schema } from "effect"
const CounterModel = Schema.Struct({
count: Schema.Number
})
const CounterMessage = UiSchema.TaggedEnum({
ClickedDecrement: {},
ClickedIncrement: {},
ClickedReset: {}
})
const Counter = Html.component({
name: "Counter",
model: CounterModel,
message: CounterMessage
}).make({
init: () => ({ count: 0 }),
update: {
ClickedDecrement: ($) => $.evolve({ count: (count) => count - 1 }),
ClickedIncrement: ($) => $.evolve({ count: (count) => count + 1 }),
ClickedReset: ($) => $.evolve({ count: 0 })
},
view: (h, model) =>
h.div(
h.p(String(model.count)),
h.button.on("click", CounterMessage.ClickedDecrement()).children("-"),
h.button.on("click", CounterMessage.ClickedReset()).children("Reset"),
h.button.on("click", CounterMessage.ClickedIncrement()).children("+")
)
})
const Main = BrowserHost.mount(Counter, {}, document.getElementById("root")!)
Layer.launch(Main).pipe(Effect.runFork)| Package | Description |
|---|---|
@effect/ui |
The framework: a host-agnostic core, @effect/ui/html for the DOM, routing, server rendering and hydration, and test harnesses |
@effect/ui-kit |
Unstyled components for @effect/ui: see its components |
@effect/ui-devtools |
Message log inspector for @effect/ui: in-page overlay with Time travel, Node MCP server (with optional dispatch), experimental WebMCP, and DevToolsHeadless for terminals |
@effect/ui-opentui |
OpenTUI terminal vocabulary and host for @effect/ui |
Every pull request and every push to main publishes snapshot builds of all four packages to pkg.pr.new. Install @effect/ui with a commit's short SHA alongside effect v4:
pnpm add effect https://pkg.pr.new/Effect-TS/ui/@effect/ui@<sha>Because the packages are not on npm yet, add any extra package URLs alongside @effect/ui using the same <sha> (installing one alone fails to resolve its @effect/ui peer from npm):
# With ui-kit and devtools
pnpm add effect \
https://pkg.pr.new/Effect-TS/ui/@effect/ui@<sha> \
https://pkg.pr.new/Effect-TS/ui/@effect/ui-kit@<sha> \
https://pkg.pr.new/Effect-TS/ui/@effect/ui-devtools@<sha>
# With OpenTUI
pnpm add effect @opentui/core@^0.9.9 \
https://pkg.pr.new/Effect-TS/ui/@effect/ui@<sha> \
https://pkg.pr.new/Effect-TS/ui/@effect/ui-opentui@<sha>@effect/ui-devtools/node also requires @effect/platform-node, and @effect/ui-opentui has its own runtime requirements.
examples/ holds runnable apps, several of them ports of Foldkit's examples. Each one is a private workspace package covered by pnpm check and pnpm lint, and by pnpm test for the examples with Vitest suites (virtual-list uses its own check-history script instead). Run a web example with pnpm --filter <name> dev. snake-tui is a terminal app: use pnpm --filter snake-tui start (Node) or start:bun.
| Example | Description |
|---|---|
auth |
Authentication flow with guarded routes and a SessionStore service |
canvas-art |
Interactive <canvas> animation using Canvas and HtmlSubscription |
counter |
The quick start above, with ui-kit Buttons, Head updates and a Story test |
counters |
Dynamic keyed list of child Counter components |
file-preview |
File picker reading local files with HtmlFiles and switch-mode Commands |
interrupting-commands |
Concurrent uploads demonstrating Command interruption and @effect/ui-devtools |
launch |
The launch site deployed to ui.effect.website |
routing |
Typed routes, lazy-loaded pages, Query, and NavigationMenu |
snake |
Snake game with keyboard Subscriptions, timers, and @effect/ui-devtools |
snake-tui |
Terminal port of snake using @effect/ui-opentui and DevToolsHeadless |
virtual-list |
Demos of @effect/ui-kit's VirtualList: see its README |
web-components |
Integrating third-party Web Components with Html.customElement |
The repository is a pnpm workspace, set up like the Effect monorepo. nix develop (or direnv) provides the toolchain.
pnpm install
pnpm check # type check sources, tests, examples and AI docs
pnpm test # run the Vitest suites in watch mode (--run for a single run)
pnpm test-types # run the TSTyche type tests
pnpm doctest # run the examples in the JSDoc
pnpm lint # oxlint and dprint
pnpm lint-fix # fix lint errors and format
pnpm jsdocs # report JSDoc diagnostics
pnpm circular # check for circular imports
pnpm codegen # regenerate the index.ts barrels
pnpm ai-docgen # regenerate LLMS.md from ai-docs/src
pnpm build # build every packageAdd a changeset (pnpm changeset) to a pull request that changes a published package.
packages/tools holds private copies of the Effect monorepo's lint plugin, barrel codegen, JSDoc checker and AI docs generator, which aren't published to npm.