CroftSoft
/
Library
/
Tutorials
Rust-Yew Project Setup
2023 Feb 12 Sun
David Wallace Croft
Links
In recommended reading order
Project Setup
-
Start by following the instructions in the
Rust Project Setup
-
Add the distribution directory to your .gitignore file
/dist
/target
-
Install trunk
cargo install --locked trunk
-
Add dependencies
cargo add yew --features csr
-
Add an index.html file to the root of your project
<!DOCTYPE html>
<html>
<head>
<meta
charset="utf-8">
<title>
[Project Name]
</title>
</head>
</html>
-
Replace src/main.rs with the following:
use yew::prelude::*;
#[function_component(App)]
fn app() -> Html {
html! {
<h1>{ "Hello, World!" }</h1>
}
}
fn main() {
yew::Renderer::<App>::new().render();
}
-
Start the trunk server
trunk serve --open
-
Verify that the Yew application is running in your browser
-
You might need to click the browser reload button
-
Commit your code changes
git add .
git commit -m "Yew project setup"
-
Push to your remote code repository
git push
© 2022-2023
CroftSoft Inc
|