Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 673 Bytes

File metadata and controls

45 lines (33 loc) · 673 Bytes

Sycamore crate - example

Runnable project

You may want/need to add a WASM target:

rustup target add wasm32-unknown-unknown

Edit file main.rs which will contain your website code:

use sycamore::prelude::*;

#[component]
fn Hello<G: Html>(cx: Scope) -> View<G> {
    view! { cx,
        p { "Hello, World!" }
    }
}

fn main() {
    sycamore::render(|cx| {
        view! { cx, Hello {} }
    });
}

Create top-level file index.html:

<!DOCTYPE html>
<html>
  <body></body>
</html>

Serve the website by using the trunk build tool:

trunk serve

Browse http://localhost:8000