CroftSoft / Library / Tutorials

Rust-Yew Project Setup

2023 Feb 12 Sun

David Wallace Croft


Contents

Links

In recommended reading order

Project Setup

  1. Start by following the instructions in the Rust Project Setup
  2. Add the distribution directory to your .gitignore file /dist /target
  3. Install trunk cargo install --locked trunk
  4. Add dependencies cargo add yew --features csr
  5. 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>
  6. 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(); }
  7. Start the trunk server trunk serve --open
  8. Verify that the Yew application is running in your browser
    • You might need to click the browser reload button
  9. Commit your code changes git add . git commit -m "Yew project setup"
  10. Push to your remote code repository git push


© 2022-2023 CroftSoft Inc

 
 
 
CroftSoft
 
 
About
Library
- Books
- Code
- Courses
- Links
- Media
- Software
- Tutorials
People
Portfolio
Update
 
 
Google
CroftSoft Web