Skip to main content

Examples

Each example is available as a starter template via Create Foldkit App. Pick one that matches what you’re building, or start with Counter and work your way up. See Getting Started to get up and running.

ExampleDescription
CounterThe classic counter example. Increment, decrement, and reset a number.
CountersAdd and remove independent Counter Submodels in a dynamic list. Each row is embedded through h.submodel and routed through a wrapper Message.
TodoA todo list persisted in localStorage. Add, complete, and delete tasks.
StopwatchA stopwatch with start, stop, and reset. Demonstrates a time-based Subscription.
Crash ViewA custom crash fallback with a button that crashes the application and an action that reloads it. Demonstrates crash.view and crash.report.
Slow WarningsTrigger slow update, view, patch, and Subscription dependency warnings at their default thresholds, then inspect them in a visible log.
FormA form with field validation, error states, and asynchronous submission.
WeatherLook up weather by ZIP code. Demonstrates HTTP requests and loading states.
API CacheQuery caching without a query client. Demonstrates stale-while-revalidate, request deduplication, invalidation, and interval refetching.
ChartingA live dashboard for public Foldkit telemetry from GitHub and npm. Demonstrates HTTP Commands, asynchronous state, an ECharts Mount adapter, and a Subscription that turns chart clicks into Messages.
RoutingA client-routed application with URL parameters, nested routes, rest segments, and navigation.
Route TransitionsA live log shows which Transition helper handles each navigation. Entering the gallery loads its catalog once, staying on a painting refetches only when its id changes, and leaving the studio saves a draft.
Interrupting CommandsSimulated file uploads driven by interruptible Commands. Cancel one upload, cancel every upload in flight, or restart a cancelled upload through a keyed interrupt registry and an outcome-carrying result Message.
View TransitionsAnimated route changes with the View Transitions API. Transition types control direction-aware slides, and a shared element morphs from gallery card to detail hero.
Query SyncA filterable dinosaur table where every control syncs to URL query parameters. Schema transforms accept valid states and replace invalid parameters with declared defaults.
SnakeThe classic snake game. Keyboard input, game loop, and collision detection.
AuthAn authentication flow with Submodels, OutMessage, protected routes, and session management.
Shopping CartAn e-commerce application with a product listing, cart management, and checkout flow.
State MachineA checkout workflow powered by the experimental state machine module. Guards skip Shipping for digital orders, gate Place order behind a complete review, and parse promo codes into applied discounts.
Pixel ArtA pixel art editor with immutable undo and redo, time-travel history, Foldkit UI components, lazy views, Subscriptions, Commands that report errors as Messages, and localStorage persistence through Flags.
Job ApplicationA multi-step form with asynchronous email validation, cross-field date constraints, file uploads, and per-step error indicators.
WebSocket ChatA ManagedResource owns a WebSocket connection lifecycle. Demonstrates connection state, reconnection, and frames entering update as Messages.
Managed Resource LayerA layer-backed ManagedResource starts a ComputeEngine service from an Effect Layer, exposes it to Commands, and runs Layer finalizers when the Model turns it off.
KanbanA drag-and-drop kanban board with cross-column reordering, keyboard navigation, fractional indexing, and screen reader announcements.
MapAn interactive MapLibre GL map with locations, search, and "find my location." Demonstrates a Mount integration with a third-party DOM library, plus a Subscription that turns map movement and marker clicks into Messages.
Canvas ArtClick the canvas to spawn bouncing balls. Demonstrates declarative 2D rendering with Canvas.view, animation-frame Subscriptions, and pointer events translated to canvas-local coordinates.
Generative ArtMove the mouse to stir a Perlin-noise flow field, then click to bloom prismatic particle bursts. Demonstrates Canvas.view with hundreds of evolving Path strokes per frame, Effect Random for spawning, and simulation controls wired through Messages.
Web ComponentsA QR code designer integrates two third-party web components through CustomElement.define. The color picker emits CustomEvents as Messages, the QR element receives typed properties, and both communicate through the Model.
EmbeddingA Foldkit widget embedded in a plain TypeScript host page through Runtime.embed. The host seeds initial state with Flags, pushes a step value in through an inbound Port, mirrors the count the widget emits through an outbound Port, and mounts and unmounts the widget with dispose. All communication crosses one Schema-typed handle; the host never touches the Model.
Static Site GenerationA build script renders every route to static HTML through a server entry, and the client hydrates the served markup in place. The same init, view, and Model produce the build output and the running application.
Server-Side RenderingA server renders each request into HTML using Flags read from a cookie, and the client hydrates with the exact values the server used. Reload the page and your latest count arrives already in the markup, before any JavaScript runs.
UI ShowcaseAn interactive showcase of every Foldkit UI component, with styled routed demos and their parent and Submodel wiring.
Personal BlogA blog whose prose lives in Markdown files. The @foldkit/markdown Vite plugin compiles each file into a typed document, per-node view overrides style the result, and directive islands place a live Counter Submodel and Note callout between paragraphs.
Typing Terminal
A production real-time multiplayer typing speed game. A full-stack Effect application with an RPC backend and Foldkit frontend.
Race your friends →