Silkenweb
A library for building reactive web apps.
Features
- No VDOM. Fine grained reactivity using signals to minimize DOM API calls.
- Uses plain Rust syntax rather than a macro DSL.
- Routing.
- Tauri support
- Server side rendering with hydration, and compile time pre-rendering.
- Downcasts Js objects for you, where the type is known at compile time. For example,
button().on_click(...)
passes your event handler aweb_sys::HtmlInputElement
and aweb_sys::MouseEvent
.
Example: A Simple Counter
use ;
use ;
Quick Start
Design Tradeoffs
No VDOM
There are potential performance advantages to using a signals based approach, as you're telling the compiler explicitly what the dependencies within your app are, at compile time. With a simple VDOM based approach, you have to figure out what changed at runtime. The tradeoff here is slightly more complex code when using a signals based approach.
What tends to happen in practice is that VDOM based approaches will add some mechanism so that every time someting changes, your app doesn't need to completely re-render the VDOM. This inevitably adds some complexity to VDOM based approaches.
No Macro DSL
There are many advantages to using plain Rust syntax:
- No macro DSL to learn.
- Code completion with
rust-analyser
. - The documentation is structured in a familiar manner, courtesy of
rustdoc
. - Code formatting with
rustfmt
. - Excellent compiler errors, courtesy of
rustc
. - Use Rust's well thought out, composable abstractions. Need control flow in your components? Use
if
,match
,dyn traits
, or whatever else Rust provides.
There's nothing to stop a macro DSL being built on top of Silkenweb, to complement the builder APIs.
The advantage of using a macro DSL is that syntax is tailored to defining document structure. Rust syntax is fairly well suited to this, so it's not much of a benefit in reality.
Learning
cargo doc --open
- Check out the examples folder
- futures-signals tutorial
- Feel free to ask any questions on our Discord channel.