Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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