Skip to main content

Foldkit is becoming Effect’s full-stack application framework.

Active frontend development is happening in Effect UI, now in public preview. Effect UI will be Foldkit’s frontend foundation.

Foldkit 0.x architecture

The docs and examples below cover the Foldkit 0.x architecture for state, effects, and views.

Predictable state

One immutable model holds your entire application state. Every change flows through a single update function. No hidden mutations, no stale closures, no surprises.

Explicit effects

Side effects are values you return from update, not imperative calls buried in handlers. Commands describe what should happen. The runtime handles when and how.

Shared structure

A 50-file application uses the same Model, Message, update, and Command structure as a 5-file application. New work has a known place, and reviews start from shared conventions.

Watch your program think.

DevTools logs every Message and lets you inspect each Model state. Select a Message to see what changed, or rewind the UI to that state.

The same runtime data is available to AI agents over MCP. They can inspect the current Model, walk Message history, rewind the UI to past states, and dispatch Messages.

This site runs on Foldkit. Look for the tab on the bottom right of this page to try DevTools live.

Learn about DevTools

Built on Effect. Inside and out.

If your backend already uses Effect, Foldkit carries the same tools and patterns into the browser. If Effect is new to your team, it is part of the learning curve.

  • Every Foldkit application is an Effect
  • The entire Model is defined by Schema
  • Commands use Effect for services, interruption, resources, and concurrency

Tests that just make sense.

Pure update functions mean pure tests. Story tests the state machine. Scene tests features through the view (clicking buttons, typing into inputs) with accessible locators. No DOM, no mocking.

Learn about testing
Story test
Scene test

Batteries included.

Routing, server rendering, UI components, composition, and browser lifecycles all use the same Model and Message flow.

Routing

Type-safe bidirectional routing. URLs parse into typed routes and routes build back into URLs. No string matching, no mismatches between parsing and building.

Explore routing

Server Rendering

Generate static HTML at build time or render each request. Both paths use the same init, view, and Model, then hydrate the HTML in the browser.

Explore server rendering

UI Components

Accessible dialogs, menus, tabs, listboxes, disclosures, and more. Each stateful component follows The Elm Architecture and stays open to styling and composition.

Browse the components

Submodels

A Submodel embeds its own Model, Messages, update, and view in a larger program. It sends domain facts to its parent as typed OutMessages. Every stateful Foldkit UI component is a Submodel.

Explore Submodels

Browser Lifecycles

Subscriptions stream events while a Model condition holds. ManagedResources hold handles such as WebSockets and AudioContext. Foldkit closes both when the Model no longer needs them.

Explore browser lifecycles

Embedding

Run a Foldkit widget inside any host application with Runtime.embed. The host pushes data in and receives values out through Schema-typed Ports, and tears the widget down with dispose.

Explore embedding

See it work.

Watch a message flow through update into the model. The code highlights in real time to show you what’s happening at each step.

import { Effect, Schema } from 'effect'
import { Command, Update } from 'foldkit'
import { defineMessageUnion } from 'foldkit/message'
import { modifyFields } from 'foldkit/struct'

// MODEL

const Model = Schema.Struct({
  count: Schema.Number,
  isResetting: Schema.Boolean,
  resetDuration: Schema.Number,
})
type Model = typeof Model.Type

// MESSAGE

const Message = defineMessageUnion({
  ClickedIncrement: {},
  ChangedResetDuration: { seconds: Schema.Number },
  ClickedResetAfterDelay: {},
  CompletedDelayReset: {},
})
type Message = typeof Message.Type

// COMMAND

const DelayReset = Command.define('DelayReset', {
  args: { seconds: Schema.Number },
  messages: [Message.CompletedDelayReset],
  execute: ({ seconds }) =>
    Effect.as(
      Effect.sleep(`${seconds} seconds`),
      Message.CompletedDelayReset(),
    ),
})

// UPDATE

type UpdateReturn = Update.Return<Model, Message>
const update = (model: Model, message: Message) =>
  Message.match<UpdateReturn>(message, {
    ClickedIncrement: () => ({
      model: modifyFields(model, { count: count => count + 1 }),
    }),
    ChangedResetDuration: ({ seconds }) => ({
      model: modifyFields(model, { resetDuration: () => seconds }),
    }),
    ClickedResetAfterDelay: () => ({
      model: modifyFields(model, { isResetting: () => true }),
      commands: [DelayReset({ seconds: model.resetDuration })],
    }),
    CompletedDelayReset: () => ({
      model: modifyFields(model, { count: () => 0, isResetting: () => false }),
    }),
  })

0

Reset Delay (seconds)

2

Model State

count: 0
isResetting: false
resetDuration: 2

Phase

Idle

Message Log

Working with Foldkit 0.x

Foldkit 0.x uses The Elm Architecture. Application state does not live in component instances or hook lifecycles. The Model is the single source of truth, and every transition stays visible in update.

The same Model and update loop drive the application in the browser and during server rendering.

Application patterns

  • Sharing Effect services

    Foldkit carries Schema, services, Streams, and scoped resources into the frontend.

  • Applications with complex state

    Auth flows, real-time data, and multi-step forms become explicit states and transitions instead of effects and refs spread across the tree.

  • Shared conventions across features

    One pattern for state, effects, and views gives features a known shape and reviews a common vocabulary.

Integration options

  • Existing React codebases

    Runtime.embed lets you run a Foldkit widget inside a React application.

  • Server-rendered routes

    Render a route for each request, then hydrate it in the browser.

  • Static deployments

    Prerender routes at build time and serve the generated HTML from a static host.

Foldkit 0.x project status

We no longer recommend starting new projects with Foldkit 0.x. We’ll keep fixing critical bugs in Foldkit 0.x at least until Effect UI ships with an upgrade guide.

For agent productivity. And human understanding.

Agents can use Foldkit’s consistent architecture to build features and inspect running apps through MCP. People can trace the same Model and Message flow to understand, review, and test the result.

Set up AI-assisted development

Foldkit 0.x resources

Find documentation, API references, and examples for existing Foldkit applications.

Stay in the update loop.

New releases, patterns, and the occasional deep dive.