Rust for behaviour, a template for the tree

vapors is a Rust GUI framework. A .wisp file contains Rust statements, CSS text and an HTML-shaped template. The component compiler turns it into Rust that builds and updates an element tree, which vapors styles, lays out and draws with wgpu natively and WebGPU in the browser.

You keep Rust’s types, closures and Cargo build. The additional language is the template: elements describe structure, expression holes display values, and event attributes connect handlers.

counter.wisp
<script>let count: Signal<i32> = Signal::new(0);let increment = move || count.update(|n| *n += 1);</script><style>:global(body) { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }button { padding: 8px 12px; }</style><button onclick={increment}>Clicked {count} times</button>
vapors component source

The template is compiled. The framework does not evaluate that Rust script as a string at run time.

State handles and ownership

A signal is a piece of reactive state that tracks its dependants and notifies them when its value changes. Signal<T> is the Rust handle to that state. Copying a signal handle refers to the same graph node; it does not copy the stored value into a separate signal. A move closure can capture the handle and update that shared state.

The current signal constructors require T: 'static. Store an owned value such as String when component state must outlive a temporary borrow. A get operation clones its value when T: Clone; the runtime also provides closure-based reads for working with a reference to the value.

The reactive graph is single-threaded. Components and their handlers operate within that runtime. Do not assume that copying a handle establishes a cross-thread update mechanism.

Reactive lifetime is explicit

Generated components, conditional branches and list rows have owners. Unmounting a component or removing a branch disposes its reactive work. Retaining a copied signal handle does not keep a disposed component usable.

Fallible operations such as try_get return an error for a disposed signal. Convenience methods such as get panic with that diagnostic. Use the fallible operations when the caller needs to handle failure. See Signals and derived state for memos, batching and effect timing.

Code generation belongs in the build

The component compiler is a build dependency. Your build script scans the component directory:

// build.rs
fn main() {
    vapors_compiler::build::compile_dir("src");
}

The crate includes the generated module index:

// src/lib.rs
include!(concat!(env!("OUT_DIR"), "/wisp.rs"));

A file such as counter.wisp produces a counter module with Counter and CounterProps. The generated type exposes mount and unmount methods and its typed state. The output calls the Dom trait. The Document in vapors-elements implements it for drawing; RecordingDom in vapors-dom implements it for tests.

Read Component files for dependencies, naming and generated methods. The source checkout and CLI commands are in Getting started.

Build and runtime errors

The compiler checks template and script syntax; Cargo checks the generated Rust types. At the documented revision, the document checks component CSS and supported rendering behavior when it updates. Component files describes the error locations.

Desktop and browser builds

The rendering path uses wgpu on desktop and WebGPU in the browser. The browser build targets wasm32-unknown-unknown and uses Trunk and generated JavaScript glue. That is a compiled application build, distinct from hosting a Rust compiler in a web page.

The demos run in both targets: cargo run -p vapors-app --example demo -- <name> opens a native window, and the hosted examples run on WebGPU. See Elements and events for supported behavior and Running in the browser for build and embedding requirements.

Learn the template in order

Start with Your first component. Then follow signals, derived values, bindings, conditions and keyed lists. The templates keep those relationships visible while the generated code remains part of an ordinary Rust crate.