Skip to content

Examples ​

Every example below is a real route of one of the demo applications. Each opens in StackBlitz on the relevant file, already navigated to the page.

The demo groups them the way you would meet them: components first, then the primitives on their own, then the same features behind services, then routing and the rest.

Just want to poke at something?

The Playground is a shareable sandbox with a small todo flow — the fastest way to try an idea.

Components ​

Functional, selectorless components rendered from typed hyperscript.

ExampleWhat it shows
Functional ComponentscraftComponent, inputs and outputs as factory parameters, hyperscript templates
Reactive CompositionComposing components and directives with .pipe(...)
Content ProjectionFree DOM content, typed DOM contracts, and logical projection by contract
Pending BlockType-safe async suspension with settledValue, settled(...) and pendingNode
Pending Block — ExceptionCoordinating pending, reloading and business-exception fallbacks with pendingNode and catchNode

Primitives ​

Using state, query, mutation, queryParams and asyncProcess directly, with no service layer.

ExampleWhat it shows
Queryquery() with reactive params, status and caching
Mutationmutation() with manual control of modification operations
List with PaginationPagination with hand-managed query params and page state
Granular MutationOptimistic updates and cache invalidation, done by hand
Full DemoEverything at once, without store or service abstractions
Login ForminsertForm, validators, and a typed submit wired to a mutation
Pixel Artstate + insertSelect over a flat array
Pixel Art MatrixNested insertSelect and internal source$ between rows and cells
ExceptionsBusiness exceptions on query(), rendered per code with matchNode.exhaustive
Exception QueryParamsqueryParams decode failures through hasException() and exceptions().parse

State machines ​

State machines for explicit transitions, history and collection-oriented UI.

ExampleWhat it shows
Profile editorcraftStateMachine, typed transitions and persisted history
Text editorA compact state machine for editing, validation and transitions
Task boardA state machine per list item with history and reactive collection updates

Services ​

The same features, packaged behind craftService.

ExampleWhat it shows
Craft QueryA reusable query service with configured storage persistence (localStorage by default)
Craft MutationCreate / update / delete with reactive cache synchronisation
Craft List PaginationqueryParams + insertPaginationPlaceholderData in a service
Craft Granular MutationinsertReactOnMutation updating cached data without a reload
Craft Full DemoQueries, mutations, async work, URL state and persistence together
craftService CounterThe smallest possible service — scopes and composition
craftService User DetailService inputs, and exposing only part of a dependency
craftRegisterForA parent driving live children through a typed registry

Effect ​

Concrete EffectTS integration examples, using the dedicated Effect demo.

ExampleWhat it shows
Profile LookupqueryEffect, typed business errors, and pending / exception rendering
Access CheckAn Effect service provided by the application Layer
Team OverviewCombining application-wide and route-scoped Effect Layers
Effect PlaygroundA shareable todo sandbox with queryEffect, mutationEffect, and a route-provided Effect service
Translate in an EffectprovideI18nRuntime as a route Layer, translateEffect inside a plain Effect program, and the locale as Craft state driving the query params

Design system ​

The typed style system, at all three of its levels. Both routes read from the same sheets under src/app/examples/design-system/, which has a README walking through the same progression in code.

ExampleWhat it shows
Mini Design SystemdefinePalette, defineStateAxis, cssVars and the theme: one dark-mode rule for the whole system, and variants as data-* attributes rather than class strings
Scroll contextLevel 3: requires(scrollPort.block) travelling up the tree, provides(...) on the layout that owns the area, and the scrollState axis

Start from Activating the style system — the sheets emit nothing without the Vite plugin.

Internationalisation ​

ExampleWhat it shows
Type-safe i18ndefineCatalog + msg + plural, a second locale through defineLocaleLike, every shipped semantic token, a custom defineToken that resolves a service and parses its parameter with a schema, and runtime.bind switching the whole page reactively

The guide is Type-safe i18n.

Routing ​

ExampleWhat it shows
Query Params in the routequeryParams declared on the route rather than in a component
Guard DemoGuards as bare generators, and handleExceptions per code
Slow PageNon-blocking navigation: the stay → blank → loader phases, and a craftGen resolver recovered locally with catchTag
View TransitionsOutlet-driven view transitions surviving the guard/resolve chain, with a per-route skeleton
Lazy LayoutA lazy child collection with its own DI check and a route-provided service

Tooling ​

ExampleWhat it shows
PlaygroundA shareable sandbox: a small todo flow with craftService, query() and mutation()
Send Context to AIExporting the live dependency graph and app context to an assistant

Notes ​

Each example ships its own api.service.ts simulating the network, so every route works standalone.

Source repository: craft-ts-demo.

Effect demo source repository: craft-demo-effect.