stunt 0.1.0

A declarative web framework for Rust/Wasm
Documentation

crates.io docs.rs GitHub License dependencies

stunt is a frontend web framework for developing reactive user interfaces with Rust.

Features

  • Macro for writing html with rust expressions, similar to that of JSX.
  • Highly extensible components.
  • Use any build tool you like eg. trunk.
  • Multiple ways to manage the state of your application.

Goals

  • Optimized DOM api calls
  • Router implementation
  • Webworker integration
  • Full Documentation

Example

use stunt::prelude::*;

pub enum Message {
    Add,
}

pub struct App {
    count: usize,
}

impl Component for App {
    type Message = Message;
    type Properties = ();

    fn create() -> App {
        App {
            count: 0,
        }
    }

    fn callback(&mut self, message: &Message) {
        match message {
            Message::Add => {
                self.count += 1;
            },
        }
    }

    fn view(&self, _properties: ()) -> Html {
        html! {
            <div>
                <button onclick={ Message::Add } >
                    { "increment" }
                </button>
                <h1>
                    { format!("count: {}", self.count) }
                </h1>
            </div>
        }
    }
}

fn main() {
    Renderer::<App>::new().render();
}

License

stunt is licensed under the MIT license.