Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

foldkit

> 编程语言
Open source

The frontend framework for correctness. Documentation · Why Foldkit · Examples · Get Started · Discord --- Foldkit is a TypeScript frontend…

748 stars0 likes0 views
WebsiteGitHub

About

The frontend framework for correctness. Documentation · Why Foldkit · Examples · Get Started · Discord --- Foldkit is a TypeScript frontend…

The frontend framework for correctness.

Documentation · Why Foldkit · Examples · Get Started · Discord


Foldkit is a TypeScript frontend framework built on Effect. It gives your entire application one architecture: a Schema-defined Model as the single source of truth, fact-named Messages, an exhaustive update function, and explicit Commands for side effects. Routing, server rendering, UI components, Submodels, and browser lifecycles all use that same Model and Message flow.

Foldkit uses The Elm Architecture instead of component-owned state and hook lifecycles. That discipline is a real commitment. Foldkit works best when the team wants shared conventions across the application and is ready to build on Effect throughout. If your backend already uses Effect, Foldkit carries the same tools and patterns into the browser: Schema, services, Streams, and scoped resources.

A Foldkit program can own the whole page or run as a widget inside an existing application, React included, through Runtime.embed. The same program can render on the server at build time or per request, then hydrate in place. Coming from React? Start here, or compare the same pixel-art editor built in both frameworks.

[!NOTE] Foldkit is in beta and under active development. The core API is stable, but breaking changes may occur in minor releases. See the changelog for details.

Get Started

create-foldkit-app scaffolds a complete setup with Tailwind, TypeScript, Oxlint, Oxfmt, and the Vite plugin for state-preserving live reload. Pick a rendering mode (browser-only SPA, static generation, or server rendering) and, for a SPA, the example to start from.

bash
npx create-foldkit-app@latest

Counter

A complete Foldkit program. State lives in a single Model, events become Messages, and a pure function handles every transition. main.ts defines the program and entry.ts boots the Runtime, so main.ts stays importable from tests without booting a Runtime as a side effect.

…
typescript
// src/entry.ts
import { Runtime } from 'foldkit'

import { Model, init, update, view } from './main'

const application = Runtime.makeApplication({
  Model,
  init,
  update,
  view,
  container: document.getElementById('root'),
})

Runtime.run(application)

Source: examples/counter.

What Ships With Foldkit

Routing, server rendering, UI components, composition, and browser lifecycles all use the same Model and Message flow. The pieces below ship as one system and are documented in depth at foldkit.dev.

  • Commands: Side effects as named Effects that return Messages and are run by the Runtime.
  • Routing: Type-safe bidirectional routing from parser combinators. URLs parse to Routes, Routes build URLs.
  • Subscriptions: External event streams declared as a function of the Model.
  • Managed Resources: Model-driven lifecycle for WebSockets, AudioContext, and other long-lived handles.
  • Mount: The seam where view code hands a real DOM element to a third-party library that owns its own DOM.
  • Submodels: A self-contained Model, update, and view that a parent embeds, wrapping child Messages in a Got* envelope.
  • OutMessage: A typed channel for a child Submodel to emit domain events up to its parent.
  • Embedding: Run a Foldkit program inside a host app through Schema-typed Ports with Runtime.embed.
  • UI Components: Accessible, keyboard-friendly primitives in the @foldkit/ui package.
  • Field Validation: Per-field validation state modeled as a discriminated union.
  • Virtual DOM: Declarative views with lazy memoization and keyed diffing, powered by Snabbdom.
  • Server Rendering: The same program rendered to HTML at build time (SSG) or per request (SSR), then hydrated in place.
  • DevTools: In-browser overlay for inspecting Messages, Model, and Commands, with time-travel.
  • DevTools MCP: Expose a running app to AI agents over the Model Context Protocol.
  • Crash View and Reporting: A custom fallback UI when the update loop throws, plus a report callback.
  • Story Testing: Exercise the update function directly, resolving Commands inline. No mocks, no fake timers.
  • Scene Testing: Drive your real view the way a user does, with accessible locators. No browser required.
  • Slow Warnings: Development warnings when update, view, patch, or Subscription extraction exceeds its budget.
  • Live Reload: Vite plugin with state-preserving reloads. Save a file, the page reloads, and your Model is restored. Change your view, keep your state.

AI-Assisted Development

Every feature has the same visible structure: a Schema-defined Model, fact-named Messages, exhaustive update, and explicit Commands. AI-generated changes follow code paths a person can inspect and test. Foldkit DevTools and its MCP server expose the same Model and Message history while the application runs.

Examples

Some of what you can build with Foldkit. See all example apps on foldkit.dev.

  • Counter: Increment/decrement with reset
  • Todo: CRUD operations with localStorage persistence
  • Form: Form validation with async email checking
  • Job Application: Multi-step form with cross-field validation, file uploads, and per-step error indicators
  • Weather: HTTP requests with async state handling
  • API Cache: Query caching with stale-while-revalidate, request deduplication, and interval refetching
  • Routing: URL routing with parser combinators
  • Route Transitions: Live transition log with entry, exit, and stayed navigation policies
  • Query Sync: URL query parameter sync with filtering and sorting
  • Snake: Classic game built with Subscriptions
  • Auth: Authentication flow with Submodels and OutMessage
  • Shopping Cart: Nested models and complex state
  • WebSocket Chat: Managed Resources with WebSocket integration
  • Kanban: Drag-and-drop kanban board with cross-column reordering and keyboard navigation
  • Pixel Art: Grid-based pixel editor with painting, erasing, and palette selection
  • UI Showcase: Interactive showcase of every Foldkit UI component
  • Static Site Generation: Build-time prerendering with client hydration
  • Server-Side Rendering: Per-request rendering on an Effect HttpServer with cookie-derived Flags
  • Typing Game: Multiplayer typing game with Effect RPC backend (play it live)

Community Projects

Building something for the Foldkit ecosystem? You're welcome to use the Foldkit name, logo, and visual language without advance permission. See the community branding guidelines.

Development

See CONTRIBUTING.md for the checks, commit conventions, and changeset expectations, and AGENTS.md for code style.

bash
git clone https://github.com/foldkit/foldkit.git
cd foldkit
pnpm install

# Build the Foldkit libraries in watch mode
pnpm dev:libs

# Run an example (in a separate terminal)
pnpm dev:example:counter

External reference repositories under repos/ are vendored in as git subtrees, so they come down with the clone. Each is pinned to the release tag matching the version this repo depends on, not a moving branch, so the reference source always matches what installs and compiles. Refresh repos/effect from the effect@ tag that matches package.json, and re-pin it whenever the effect dependency is bumped:

bash
VER=$(node -p "require('./packages/foldkit/package.json').devDependencies.effect")
git subtree pull --prefix=repos/effect https://github.com/Effect-TS/effect.git "effect@${VER}" --squash

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言