stunt 0.1.1

A declarative web framework for Rust/Wasm
Documentation

crates.io docs.rs GitHub License

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 with support for passing down properties.
  • 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
  • Support for desktop and mobile.

Usage

This crate is on crates.io and can be added either through adding stunt to your dependencies in Cargo.toml:

[dependencies]
stunt = "0.1.1"

Or running the following Cargo command in your project directory:

cargo add stunt

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, _: ()) -> Html {
        html! {
            <div>
                <button onclick={ Message::Add } >
                    { "increment" }
                </button>
                <h1>
                    { self.count }
                </h1>
            </div>
        }
    }
}

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

License

stunt is licensed under the MIT license.