* rewrite router * add support for 404 routes * support base urls * parse query params * don't use js snippets lol * cleanup code, update example * bruh fmt * test router * add more tests * wasm_test feature, CI * Add rustdocs * update docs on website * use enum for routes, add derive macro for it * fix 404 handling * fix tests * formatting * update docs, little cleanup * fix example * misc fixes * add routable macro tests * document routable macro, rustfmt * fix test, add makefile * Replace the children based API with callback based one * update example * update docs * update Cargo.toml * clippy & fmt * cleanup code * apply review * more fixes from review * fix warnings * replace function component with struct component, update docs * formatting * use `href` getter instead of reading attribute * apply review * use serde to parse query parameters * use js_sys::Array for search_params + formatting * fix doc test * Apply suggestions from code review Co-authored-by: Simon <simon@siku2.io> * Update docs/concepts/router.md apply suggestion Co-authored-by: Simon <simon@siku2.io> * apply review (part 2) * use serde for parsing query * a more modular implementation * docs for query parameters * fix doc * Apply suggestions from code review Co-authored-by: Simon <simon@siku2.io> * fixes (from review) * formatting * use new functions * not_found returns `Option<Self>`, to_route -> to_path * Apply suggestions from code review Co-authored-by: Simon <simon@siku2.io> * remove PartialEq + Clone bound * docs * fix example Co-authored-by: Simon <simon@siku2.io>
Yew Examples
How to run
The examples are built with trunk. You can install it with the following command:
# at some point in the future, trunk will automatically download wasm-bindgen
cargo install trunk wasm-bindgen-cli
Running an example is as easy as running a single command:
# move into the directory of the example you want to run
# In this case it's the todomvc example
cd examples/todomvc
# build and serve the example
trunk serve --release
We're also publicly hosting the examples at https://examples.yew.rs/<EXAMPLE>.
As an example, check out the TodoMVC example here: https://examples.yew.rs/todomvc
List of examples
| Example | Description |
|---|---|
| boids | Yew port of Boids |
| counter | Simple counter which can be incremented and decremented |
| crm | Shallow customer relationship management tool |
| dashboard | Uses the fetch and websocket services to load external data |
| dyn_create_destroy_apps | Uses the function start_app_in_element and the AppHandle struct to dynamically create and delete Yew apps |
| file_upload | Uses the reader service to read the content of user uploaded files |
| futures | Demonstrates how you can use futures and async code with Yew. Features a Markdown renderer. |
| game_of_life | Implementation of Conway's Game of Life |
| inner_html | Embeds an external document as raw HTML by manually managing the element |
| js_callback | Interacts with JavaScript code |
| keyed_list | Demonstrates how to use keys to improve the performance of lists |
| mount_point | Shows how to mount the root component to a custom element |
| multi_thread | Demonstrates the use of Web Workers to offload computation to the background |
| nested_list | Renders a styled list which tracks hover events |
| node_refs | Uses a NodeRef to focus the input element under the cursor |
| pub_sub | Cross-component communication using Agents |
| router | The best yew blog built with yew-router |
| store | Showcases the yewtil::store API |
| timer | Demonstrates the use of the interval and timeout services |
| todomvc | Implementation of TodoMVC |
| two_apps | Runs two separate Yew apps which can communicate with each other |
| webgl | Controls a WebGL canvas from Yew |
Next steps
Have a look at Yew's starter templates when starting a project using Yew – they can significantly simplify things.
Help out
If one of the examples catches your interest, look for the "improvements" section in its README file.
Most examples list a few ideas for how to improve them.
Consider starting with those but don't hesitate to improve an example in other ways either.
One problem that currently plagues most examples is the lack of styling. Please help us make the examples look as flashy as possible!