vertigo 0.14.5

Reactive Real-DOM library with SSR for Rust
Documentation

Vertigo

A reactive Real-DOM library with SSR for Rust.

crates.io Documentation MIT or Apache 2.0 licensed Dependency Status CI downloads

Features

  • Reactive dependencies - A graph of values and clients (micro-subscriptions) that can automatically compute what to refresh after one value changes
  • Real DOM - No intermediate Virtual DOM mechanism is necessary
  • HTML/CSS macros - Allows to construct Real DOM nodes using HTML and CSS
  • Tailwind v4 support out of the box
  • Isomorphic server-side rendering - The same WASM code is used for both client and server (see: vertigo-cli)
  • Fullstack - Can be mounted into actix-web (see: vertigo-cli)

See Changelog for recent features.

Go to TUTORIAL if you want to try.

Having trouble with cargo install vertigo-cli? Check BUILDING.md.

For more information go to vertigo home website vertigo.znoj.pl.

Examples

Dependencies:

vertigo = "0.14"

Example 1:

use vertigo::{dom, DomNode, Value, bind, main};

#[main]
pub fn app() -> DomNode {
    let count = Value::new(0);

    let increment = bind!(count, |_| {
        count.change(|value| {
            *value += 1;
        });
    });

    let decrement = bind!(count, |_| {
        count.change(|value| {
            *value -= 1;
        });
    });

    dom! {
        <html>
            <head/>
            <body>
                <div>
                    <p>"Counter: " { count }</p>
                    <button on_click={decrement}>"-"</button>
                    <button on_click={increment}>"+"</button>
                </div>
            </body>
        </html>
    }
}

Example 2:

use vertigo::{css, component, DomNode, store, Value, dom, main};

#[component]
pub fn MyMessage(message: Value<String>) {
    dom! {
        <p>
            "Message to the world: "
            { message }
        </p>
    }
}

#[store]
fn state_message() -> Value<String> {
    Value::new("Hello world!".to_string())
}

#[main]
fn app() -> DomNode {
    let main_div = css! {"
        color: darkblue;
    "};

    dom! {
        <html>
            <head/>
            <body>
                <div css={main_div}>
                    <MyMessage message={state_message()} />
                </div>
            </body>
        </html>
    }
}

Take a look at More examples here.

Coming from Leptos, Yew or Dioxus

Most of what you know carries over, but a few habits don't:

Leptos, Yew, Dioxus vertigo
Browser APIs wasm-bindgen, web-sys, js-sys No wasm-bindgen. The browser is reached through get_driver() and js!. Crates that need wasm-bindgen (gloo, reqwest in the browser, getrandom with js or wasm_js) won't load.
Server-side rendering The app is compiled again, natively, for the server The same .wasm runs on the server and in the browser. One build, no server and client feature flags.
Talking to the backend reqwest, gloo-net, server functions (Leptos, Dioxus) RequestBuilder and LazyCache, against a plain HTTP API. During SSR the server makes the same requests.
Components Yew and Dioxus run them again when state they read changes, and keep it in hooks They run once, when mounted (as in Leptos). State is Value and Computed.
DOM updates Yew and Dioxus diff a virtual DOM Real DOM, updated right where a value is used
JSON serde #[derive(AutoJsJson)]
Tooling trunk, cargo-leptos, dx vertigo-cli: vertigo new, watch, build, serve

The guide for coding agents covers these in more detail, with examples. It is short enough for humans too.

Installation of vertigo-cli tool

To ease process or development use vertigo-cli tool that allows to build, serve and watch your project.

cargo install --force vertigo-cli

Coding with AI agents

vertigo new puts an AGENTS.md (and a CLAUDE.md pointing to it) in the new project. It lists the project's commands and tells the agent where to find the guide for coding agents, which ships inside the vertigo crate. So the agent reads the guide for the version the project builds with, not what it remembers about an older one. Pass --no-agent-files to leave them out.

For an existing project, copy the template's AGENTS.md.

Demo App

Prepare

Install just (1.46 or newer) and vertigo-cli:

  • cargo install just vertigo-cli

Run

Build and run project using:

  • just demo

Eventually terminal will let you know that app is available under http://localhost:4444/

If you want to play around with the demo code, run:

  • just demo-watch

It should automatically recompile upon changes and the browser tab should be informed to refresh. Note that this compiles the code in debug mode so the WASM is not optimized.


To run the examples in watch mode (they will run on localhost:4444): just examples-counter or just examples-router or just examples-trafficlights

A community, soon to grow