2 releases

0.1.1 Apr 30, 2021
0.1.0 Apr 29, 2021

#95 in GUI

Download history 55/week @ 2021-04-23 108/week @ 2021-04-30 3/week @ 2021-05-07 3/week @ 2021-05-14 4/week @ 2021-05-21 2/week @ 2021-05-28 2/week @ 2021-06-04 5/week @ 2021-06-11 1/week @ 2021-06-18 2/week @ 2021-06-25 2/week @ 2021-07-02 2/week @ 2021-07-09 4/week @ 2021-07-16

55 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

19KB
384 lines

Silkenweb

tests crates.io Documentation MIT/Apache-2 licensed

A library for building reactive single page web apps.

Features

  • Fine grained reactivity using signals to minimize DOM API calls
  • No VDOM. Calls to the DOM API and your rendering code are minimized using signals.
  • Uses plain Rust syntax rather than a macro DSL
  • Downcasts Js objects for you where the type is known at compile time. For example input().dom_element() returns a web_sys::HtmlInputElement, and button().on_click(...) passes your event handler a web_sys::HtmlInputElement and a web_sys::MouseEvent.

Example: A Simple Counter

use silkenweb::{
    elements::{button, div, p},
    mount,
    signal::Signal,
};

fn main() {
    let count = Signal::new(0);
    let set_count = count.write();
    let inc = move |_, _| set_count.replace(|&i| i + 1);
    let count_text = count.read().map(|i| format!("{}", i));

    let app = div()
        .child(button().on_click(inc).text("+"))
        .child(p().text(count_text));

    mount("app", app);
}

Quick Start

rustup target add wasm32-unknown-unknown
cargo install trunk wasm-pack
cargo install wasm-bindgen-cli --version 0.2.73
cd examples/counter
trunk serve --open

Learning

Dependencies

~140KB