Documentation / Reference

Browser & desktop

A shared application layer, with a host built for each platform.

Mount into the DOM

The browser adapter translates Refract views into DOM nodes and CSS. The default mount creates an open ShadowRoot on an unused host element. Set shadow: false in mount options for light DOM.

Browser host (excerpt)
let mounted = refract_web::mount(
    host_element,
    counter(),
    refract_web::MountOptions::default(),
)?;

// Keep the mount alive for the lifetime of the UI.
// mounted.dispose() releases nodes, listeners, and state.
i

Keep the returned Mount alive. Dropping it or calling dispose releases the UI. A disposed shadow mount leaves its ShadowRoot attached; use a fresh host for a new shadow mount.

Render in a native window

The desktop adapter shares the graph, views, state, environment, and effects. It draws with a GPU renderer instead of embedding a browser. It does not turn controls into platform-native widgets.

main.rs
use refract::prelude::*;
use refract_desktop::{DesktopOptions, run};

fn main() -> refract_desktop::Result<()> {
    run(
        DesktopOptions {
            title: "Hello, Refract".into(),
            ..Default::default()
        },
        |_desktop| text("Hello from Rust").font_size(24.0),
    )
}

Follow the update

An event changes graph state. The runtime evaluates affected mounted views and prepares semantic patches. The host applies those patches to retained elements, then the core commits the new baseline and runs effects.

The browser coalesces work into a microtask, with no permanent frame loop. On desktop, unchanged text shaping and layout can be reused; the Vello renderer still repaints a complete scene. Incremental view updates are not damage-region GPU rendering.

Know the current boundaries

Desktop support has been exercised on macOS. Desktop accessibility, virtualized lists, general device-loss recovery, and a cross-thread message bridge remain future work.

Platform services are injected into shared views. The portable graph and core have no browser, renderer, text-engine, or async-executor dependency. The desktop renderer can be replaced through run_with_renderer.