A familiar component format

vapors takes inspiration from Svelte’s single-file components: a script, a stylesheet and an HTML-shaped template live together. In vapors, the script is Rust, the file extension is .wisp, and the compiler generates Rust.

The resemblance is in how you describe an interface. vapors does not compile .svelte files or run JavaScript component logic. It builds its own element tree and draws it with wgpu in a native window, or with WebGPU into a canvas in the browser; it does not create browser DOM elements.

Translate the state model

In Svelte 5, a counter and a derived value can be written like this:

<script>
  let count = $state(0);
  let doubled = $derived(count * 2);
</script>

<button onclick={() => count += 1}>Count: {count}</button>
<p>Double: {doubled}</p>

Svelte’s $state and $derived are compiler-supported runes. vapors expresses this example with typed Rust signal and memo handles:

derived.wisp
<script>let count: Signal<i32> = Signal::new(0);let doubled: Memo<i32> = Memo::new(move || count.get() * 2);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}>Count: {count}</button><p>Double: {doubled}</p>
vapors component source

Signal<i32> is the stored count. Memo<i32> derives the double. The handler changes the signal through update; the text expressions read the values. The explicit annotations become fields on the generated component.

Familiar concepts, different syntax

In SvelteIn vapors
A .svelte componentA .wisp component compiled to Rust
A component <style>, scoped to the componentA style section, scoped to the component; the framework models its rule on Svelte 5’s
:global(...) and :global { ... }:global(...) on a top-level compound; no :global block
JavaScript or TypeScript in the scriptRust statements and closures
$stateAn explicitly typed Signal<T>
$derivedAn explicitly typed Memo<T>
A property from $props()A typed #[prop] let declaration with a default
{#if ...}{if ...} with an explicit signal read
{#each ...}{for ...} with an optional key expression
{#snippet name(param)} and {@render name(arg)}{snippet name(param: Type)} and {render name(arg)}, with typed, reactive parameters
children from $props() and {@render children()}#[prop] let children: Snippet and {render children()}
bind:this={element}bind:this={signal} on an element, giving a Signal<Option<NodeId>>; not on a component tag
A callback prop for a component’s own events#[dispatcher(a, b)] let events; in the child; ona={...} on its tag
A binding such as bind:valuebind:value or bind:checked connected to a typed Rust signal

The table maps concepts; the forms are not interchangeable. Use the template reference for exact vapors syntax. Svelte’s component overview and props documentation describe the Svelte side of the comparison.

Check how values reach a child

vapors reads an ordinary prop when the child mounts. A later change to the value used by its parent is not automatically resent. A prop typed as Signal<T> shares a reactive handle with the child.

Do not infer prop-update behaviour from a familiar-looking component tag. Choose the prop type deliberately. The composition lesson follows the current two-file example.

HTML and CSS describe a different runtime

A browser normally supplies layout, focus behaviour, accessibility and a large set of DOM APIs. Those do not become available inside a vapors template because the tag names look familiar. Elements and events records what the documented revision renders, which events it fires and its accessibility limits. Template loops work even where HTML list tags are not yet supported.

Classes are toggled with class:name={bool}, as in Svelte, but class={expression} and style={expression} are refused at build time. The build sees every class name an element can have; a class string computed at run time would hide names from it. Use class="fixed" plus one class:name={bool} per class that toggles, and put declarations in the style section. A component’s style section is scoped to the elements that component creates. The framework models its rule on Svelte 5’s: a scoped rule gains one attribute’s specificity, however many compounds it has. vapors marks the component’s elements with a data-wisp attribute rather than a generated class name. :global(...) leaves a compound unscoped; a :global { ... } block is not supported. The CSS engine refuses unknown properties and unsupported forms with a line and column, where a browser drops them. Some properties it parses, such as transitions and transform, are refused by the element tree until they are implemented. Read CSS and styling for the details.

Understand the generated code

The generated API mounts a component, exposes its state and lists its current roots. Unmounting disposes its reactive owner and removes its nodes. Signals and effects run in the framework’s single-threaded runtime; the state reference gives its update and disposal rules.

Generated Rust can be read and debugged. There is no component inspector, hot reload or language server at this revision. The website repository includes a local VS Code extension for .wisp syntax highlighting; it does not provide compiler diagnostics.

Start here

  • Follow State and events to connect the familiar counter to Rust types and closures.
  • Read Templates and events before translating a Svelte template.
  • Use Getting started to check the source locally.
  • See the examples for the framework’s component demos and the image viewer. Editing components in the browser is planned, not available.