#html #dom #web

nightly sauron

An html library for building client side webapps

16 releases (9 breaking)

✓ Uses Rust 2018 edition

new 0.20.0 Nov 10, 2019
0.10.2 Oct 28, 2019
0.10.0 Jul 25, 2019

#15 in Template engine

Download history 30/week @ 2019-07-28 57/week @ 2019-08-04 18/week @ 2019-08-11 25/week @ 2019-08-18 27/week @ 2019-08-25 50/week @ 2019-09-01 31/week @ 2019-09-08 52/week @ 2019-09-15 42/week @ 2019-09-22 49/week @ 2019-09-29 28/week @ 2019-10-06 36/week @ 2019-10-13 39/week @ 2019-10-20 43/week @ 2019-10-27 69/week @ 2019-11-03

165 downloads per month
Used in 1 crate

MIT license

3.5K SLoC


Latest Version Build Status MIT licensed


   One crate to rule the DOM
   One crate to find the elements
   One crate to bring JSON
   And in the Rust code bind Strings

   This code, no other, is made by code elves
   Who'd pawn parent process to get it themselves
   Ruler of net troll and mortal and hacker
   This code is a lib crate for Patreon backers
   If trashed or buggy it cannot be remade
   If found send to Ivan, the bandwidth is prepaid

Sauron is an html web framework for building web-apps with the goal of closely adhering to The Elm Architecture, a paragon for elegant design.

As with elm, sauron doesn't use macros to provide the view, instead just using plain rust function calls to construct the view.


use sauron::html::attributes::*;
use sauron::html::events::*;
use sauron::*;
use sauron::Component;
use sauron::Node;
use sauron::Program;
use sauron::Cmd;
use wasm_bindgen::prelude::*;
use log::*;

#[derive(Debug, PartialEq, Clone)]
pub enum Msg {

pub struct App {
    click_count: u32,

impl App {
    pub fn new() -> Self {
        App { click_count: 0 }

impl Component<Msg> for App {

    fn view(&self) -> Node<Msg> {
            [class("some-class"), id("some-id"), attr("data-id", 1)],
                        value("Click me!"),
                        onclick(|_| {
                            trace!("Button is clicked");
                text!("Clicked: {}", self.click_count),

    fn update(&mut self, msg: Msg) -> Cmd<Self, Msg> {
        trace!("App is updating from msg: {:?}", msg);
        match msg {
            Msg::Click => {
                self.click_count += 1;


pub fn main() {


    <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
    <title>Minimal sauron app</title>
    <script src='pkg/minimal.js'></script>
    <script type=module>

Note: You need to use the nightly compiler with minimum version: rustc 1.37.0-nightly (17e62f77f 2019-07-01)

Build using

$> wasm-pack build --target no-modules

Look at the examples and the build script for the details.

Warning: You need to use the latest nightly compiler in order for this to work.


cargo install wasm-pack
cargo install basic-http-server

This project is based on the existing projects:



Please support this project:

Become a patron

Please contact me: ivanceras[at]gmail.com

License: MIT


~10K SLoC