Consecuit

crates.io crates.io

An experimental functional web UI framework that uses the Rust type system for hooks and more.

How is this different from other frameworks?

Other Functional UI Frameworks:

Consecuit:

What does it look like?

Take a look at our TodoMVC (and see its source code).

Or if you want something simpler, here is the code for a counter.

```rust use consecuit::prelude::; use consecuit_html::prelude::; use wasm_bindgen::prelude::*;

[wasm_bindgen(start)]

pub fn run() -> Result<(), JsValue> { mount(counter); Ok(()) }

fn counter(cc: ComponentBuilder, : ()) -> impl ComponentReturn { let (cc, (count, setter)) = cc.hook(usestate, 0);

let setter1 = setter.clone();
let decrement = Callback::new(move |_ev| {
    setter1.update_with(|v| v - 1);
});

let increment = Callback::new(move |_ev| {
    setter.update_with(|v| v + 1);
});

cc_tree!(
    <button {html_props().onclick(decrement)}>"-"</button>
    {count.to_string()}
    <button {html_props().onclick(increment)}>"+"</button>
)

} `` There are more counter examples [here](https://github.com/wishawa/consecuit/tree/main/examples/counters/src/lib.rs) (with live demo [here](https://wishawa.github.io/consecuit/counters/)), including one without macro and one with logic extracted into ause_counter` function.

The docs have more info on creating components and hooks.

This crate uses unsafe.

Don't worry. All publicly exposed function is safe.