Skip to content
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.
Branch: master
Clone or download
ivanceras Add more docs in the most critical part of the system which is the Pr…

The cmd from update is emitted here, prior to updating the dom
Latest commit f898f95 May 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Transfer Component into its own module Apr 20, 2019
crates/sauron_vdom Use vec in adding children and attributes in Node May 16, 2019
examples Fix examples to return Cmd in Component update functions May 17, 2019
src Add more docs in the most critical part of the system which is the Pr… May 17, 2019
tests Fix examples to return Cmd in Component update functions May 17, 2019
.gitignore Initial commit Apr 15, 2019
.gitlab-ci.yml Initial commit Apr 15, 2019
.travis.yml Try add codecoverage script Apr 27, 2019
Cargo.toml Add example on fetching data from a rest api May 16, 2019 Add changelog May 17, 2019
LICENSE Add more details into the package for publishing Apr 15, 2019 Add tip in readme Apr 27, 2019
codecov.yml Add codecov.yml for code coverage Apr 27, 2019
rustfmt.toml Use rustfmt config that suites sauron code, especially with the Visua… Apr 27, 2019 Initial commit Apr 15, 2019 A more concise example in README Apr 16, 2019


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 to closely adhere to The Elm Architecture, A true king for elegant design.

As with elm, sauron don't use macro to provide the view, instead just uses plain rust function calls to construct the view.


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

#[derive(Debug, 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(|_| {
                            sauron::log("Button is clicked");
                text(format!("Clicked: {}", self.click_count)),

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


pub fn main() {
    Program::new_append_to_mount(App::new(), &sauron::body());


    <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>

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
  • TIP: Use indent_style = "Visual"in your rustfmt.toml This will visually align the view function in your code, which gives it a more pleasant semantic look

This project is based on the existing projects:

Performance: Is not too bad.


Please support this project:

Become a patron

Personal plug:

I'm actively looking for a job that has to do with rust. Please contact me: ivanceras[at]

License: MIT

You can’t perform that action at this time.