// PUBLIC PREVIEW
Effect UI is a frontend library built on Effect and the Elm Architecture: self-contained Components with explicit state transitions and side effects as values. It continues the work of Foldkit 0.x (foldkit.dev), which we announced as the "new frontend foundation" in Foldkit Joins Effect.
Effect UI is in public preview. If you're building with Foldkit 0.x, the migration will be an upgrade, not a rewrite.
We built this page with Effect UI. You can read its source on GitHub.
Not reading all that? Copy a prompt to explore it with an AI agent.
Here's how Effect UI works, and the main changes from Foldkit 0.x:
- Foldkit 0.x is the existing frontend framework atfoldkit.dev .
- Effect UI is the new frontend library that continues the work of Foldkit 0.x. You import it from
@effect/ui. - Foldkit is the future full-stack framework. Effect UI will be its frontend.
Foldkit 0.x used the Elm Architecture, with the whole app as one program: one Model, one update and one view. That made every state change easy to follow, but it had costs as an app grew. Every Message ran the view from the root. Every parent stored state and forwarded Messages for its children. No part of an app could load in its own chunk.
Effect UI keeps the Elm Architecture and applies it to each Component. A Component is an Elm Architecture program of its own, and you build an app by composing Components.
A Component is self-contained. Its parent doesn't store its state or forward its Messages, so you can write and test it on its own. A Component can provide its own services and load in its own chunk. If a Component fails, the rest of the app keeps running.
This counter shows the core parts of a Component. One definition holds its Model, Messages, init, update, subscriptions and view.
Click "+1", then click the Effect UI button in the bottom-right corner. DevTools lists the Message you sent and what it changed.
A Component works the same on every platform. Only the platform-specific pieces change: the view elements, the host you mount onto and the effects that interact with them. For example, Html.component and HtmlCommand.focus target HTML, while OpenTui.component and OpenTuiCommand.focus in @effect/ui-opentui target the terminal.
In Foldkit 0.x, every Message went through the root update and re-ran the view from the root. In Effect UI, the runtime delivers a Message straight to its Component's update and re-runs only that Component's view, skipping every parent.
Both examples below build a Page that shows or hides a Counter. A parent no longer stores, wraps or forwards anything for its children. Here, Page drops from 62 lines to 34, and Counter's view only re-runs when its props change.
As a Component grows, you can still move init, update, subscriptions and view into functions of their own. The Component definition's helpers supply their types, so you don't have to annotate them.
In Foldkit 0.x, a shared parent held state that several Submodels needed in its Model. Every parent between them passed that state down. To change it, a Submodel returned an OutMessage, and every parent forwarded it back up to the owner.
In Effect UI, a Provider shares part of its Model with Components inside it, at any depth. Components inside read that state and send the Provider Messages directly, without passing anything through the parents in between.
In Foldkit 0.x, the Model held fetched data, and the parent managed the Query. The parent stored the query state, forwarded its Messages and decided when to load or refresh. In Effect UI, you define a query once and list it on the Components that need it. The runtime fetches the data and keeps it in one cache for every Component.
- Fetching The runtime fetches when the Component renders, and again when the query's arguments change. Setting
debouncewaits until the arguments stop changing. - Caching The runtime keeps one result per query and arguments. Components that ask for the same data share one fetch.
- Freshness A result older than
staleTimestays on screen while the runtime refetches it. - States Each result is an
AsyncResult: either no result yet, failure or success.
Also built into queries
- polling
- refetch on focus and reconnect
- load more
- invalidation from Commands
- optimistic updates
- prefetch on link hover
- server rendering
- restore on back and forward
In Foldkit 0.x, one Model held all of an app's state. In Effect UI, state is stored in four places:
| State | Stored in |
|---|---|
| A Component's own state | Its own Model |
| State a parent or a Provider owns | Another Component's Model |
| Data a query fetched | The runtime's query cache |
| Which Commands are running | The runtime |
A Model holds only the state that its own update changes, not everything the view shows. With logging enabled, you can still replay a Component's recorded Messages, because the log includes what update read from props, queries and Providers.
Headless Components in Effect UI manage behavior, keyboard handling and ARIA while you write the markup. Instead of returning markup of its own, a headless Component gives your view parts that you apply to your own elements, classes and children. Here, Details renders a Disclosure:
To write one, define parts instead of a view:
You can package your own reusable behavior the same way.
@effect/ui-kit already ships 41 components, so you don't have to build accessible UI from scratch. The kit has every component in Base UI, plus VirtualList, VirtualKeyboard, DirectionProvider and Positioning. They're all headless. Each handles keyboard, focus and ARIA while you write the markup and styles.
Here is the full set of 41 components. Hover or tap to animate.
Effect UI renders through a host instead of tying Components to the browser DOM. The browser host renders DOM nodes, the server host writes HTML and the test host builds an in-memory tree, all from the same HTML Components.
Other platforms bring their own elements and host, like @effect/ui-opentui for the terminal, sharing the Component runtime without translating views across platforms. You pick the host when mounting the app, and the host interface is public if you want to write your own.
A Story test sends Messages directly to a Component's update, and a Scene test drives it through the view. You pass the Component, and the test starts from its init Model, or a state you supply with given.
A test can also supply test values for everything around the Component: a query's result, a Subscription's value, an event from a child, a Provider's value or new props from the parent.
You can also replay a recorded session with Story.fromLog. When logging is enabled, the runtime records every Message a Component receives, along with the props, query results and Provider values its update read. Story.fromLog re-runs those Messages against update without running Commands, and reports the first step where the Component produces a different Model, Command or event.
Play is a new kind of test in Effect UI. In Story and Scene tests, you resolve each Command by hand, so the Command itself never runs. A Play test mounts the Component and its children on the test host. It runs their real Commands, Subscriptions and query fetches against the Layers the test provides.
A Play test can cover a whole flow. It clicks a button, lets the real Command run and checks what is on screen afterwards, with no browser and no DOM.
TestClock controls time, so delayed flows run instantly without waiting in real time.
Effect UI has an inspector that you add with one Layer, DevTools.layer. It's running on this page, behind the Effect UI button in the bottom-right corner.
- Timeline One list holds every Message from every Component, the Model after it and what changed.
- Cause and effect For any entry, DevTools traces what sent the Message, the Commands it issued and how each one ended.
- Time travel Pick an earlier entry to see the page at that point. The live app keeps running, and Resume returns to it.
- For agents An MCP server gives an agent the same view. It can read the log, inspect a Component's state and show the page at any entry. If you allow it, the agent can also send Messages.
In js-framework-benchmark, Effect UI scored 4.06× vanilla JavaScript across the nine script operations, compared to 6.27× for Foldkit 0.x. It reached first paint in 363 ms instead of 737 ms, and used 4.1 MB of memory with 1,000 rows instead of 6.1 MB. We ran all seven entries on the same machine.
| Median time running JavaScript per operation | |||||||
|---|---|---|---|---|---|---|---|
| Workload | Vanilla JS | Effect UI | React | Foldkit 0.x | Vue | Svelte | Solid |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Create 1,000 rows | 7.1 milliseconds | 22.5 milliseconds | 24.2 milliseconds | 47.3 milliseconds | 23.8 milliseconds | 12.0 milliseconds | 12.5 milliseconds |
| Replace 1,000 rows | 14.7 milliseconds | 33.7 milliseconds | 42.8 milliseconds | 57.0 milliseconds | 36.8 milliseconds | 23.7 milliseconds | 21.6 milliseconds |
| Update every 10th row4× CPU throttle | 1.3 milliseconds | 23.2 milliseconds | 12.8 milliseconds | 25.5 milliseconds | 8.0 milliseconds | 3.6 milliseconds | 3.1 milliseconds |
| Select a row4× CPU throttle | 1.2 milliseconds | 7.5 milliseconds | 9.0 milliseconds | 10.8 milliseconds | 3.9 milliseconds | 7.1 milliseconds | 2.5 milliseconds |
| Swap two rows4× CPU throttle | 0.8 milliseconds | 7.5 milliseconds | 70.0 milliseconds | 8.6 milliseconds | 4.0 milliseconds | 4.3 milliseconds | 3.5 milliseconds |
| Remove a row2× CPU throttle | 1.0 milliseconds | 3.6 milliseconds | 3.6 milliseconds | 4.7 milliseconds | 10.3 milliseconds | 1.7 milliseconds | 1.2 milliseconds |
| Create 10,000 rows | 69.1 milliseconds | 183 milliseconds | 428 milliseconds | 408 milliseconds | 209 milliseconds | 104 milliseconds | 94.4 milliseconds |
| Append 1,000 rows | 7.3 milliseconds | 24.8 milliseconds | 25.5 milliseconds | 45.3 milliseconds | 23.1 milliseconds | 12.1 milliseconds | 10.9 milliseconds |
| Clear 1,000 rows4× CPU throttle | 34.6 milliseconds | 42.2 milliseconds | 67.0 milliseconds | 61.6 milliseconds | 56.8 milliseconds | 39.3 milliseconds | 42.3 milliseconds |
| Page load and memory | |||||||
|---|---|---|---|---|---|---|---|
| Workload | Vanilla JS | Effect UI | React | Foldkit 0.x | Vue | Svelte | Solid |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Compressed size | 2.5 kilobytes | 51.9 kilobytes | 51.4 kilobytes | 86.8 kilobytes | 23.3 kilobytes | 9.7 kilobytes | 4.5 kilobytes |
| First paint | 71.9 milliseconds | 363 milliseconds | 395 milliseconds | 737 milliseconds | 165 milliseconds | 95.7 milliseconds | 71.5 milliseconds |
| Memory after load | 0.6 megabytes | 1.2 megabytes | 1.2 megabytes | 2.3 megabytes | 0.9 megabytes | 0.7 megabytes | 0.6 megabytes |
| Memory with 1,000 rows | 1.9 megabytes | 4.1 megabytes | 4.4 megabytes | 6.1 megabytes | 3.9 megabytes | 2.9 megabytes | 2.7 megabytes |
- Services per Component
Component.providegives services to a Component and everything below it. Its Commands and Subscriptions use them, and TypeScript reports a missing service at compile time. - Code splitting Load a Component from a chunk of its own with
Component.lazy. The browser loads the chunk the first time the Component renders, so it stays out of the initial bundle. - Control overlapping Commands When an update issues a Command that is still running, use
concurrentto run both,switchto interrupt the earlier run orqueueto wait for it.
Effect UI keeps these parts of Foldkit 0.x:
- A constrained, agent-friendly architecture
- Predictable state changes
- Side effects as values that the runtime runs
- Clear, readable tests focused on behavior, not plumbing
- A Message log you can inspect and replay
Effect UI isn't on npm yet. Every commit to main is published as a snapshot build on pkg.pr.new. To install the latest one:
pnpm add effect \
https://pkg.pr.new/Effect-TS/ui/@effect/ui@main \
https://pkg.pr.new/Effect-TS/ui/@effect/ui-kit@main
To stay on one build, replace main with a commit's short SHA.
The examples in the repository are complete apps you can read and run.
- Public preview: Effect UI doesn't have everything Foldkit 0.x has yet, and we're sharing it early so you can try the APIs and help shape it.
- Keep building on Foldkit 0.x: Feature work has moved to Effect UI, and Foldkit 0.x will keep getting critical bug fixes until Effect UI ships with an upgrade guide.
- Issues and PRs: Development happens inEffect-TS/ui . We'll transfer relevant Foldkit issues and PRs there, so you don't need to open them again.
Thank you to everyone building with Foldkit 0.x. What you've made with it, and what you've told us along the way, is what Effect UI is built on.