CroftSoft / Library / Tutorials

Rust-Yew Project Setup

2022-11-22

David Wallace Croft


Contents

Links

In recommended reading order

Project Setup

  1. Start by following the instructions in the Rust Project Setup
  2. Add dependencies cargo add yew
  3. 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>
  4. Replace src/main.rs with the following: use yew::prelude::*; #[function_component(App)] fn app() -> Html { html! { <h1>{ "Hello, World!" }</h1> } } fn main() { yew::start_app::<App>(); }
  5. Start the trunk server trunk serve --open
  6. Verify that the Yew application is running in your browser
    • You might need to click the browser reload button
  7. Add the distribution directory to your .gitignore file /dist /target
  8. Commit your code changes git add . git commit -m "Yew project setup"
  9. Push to your remote code repository git push


© 2022 CroftSoft Inc

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