https://github.com/arwinneil/wasm-router
Playground for a WebAssembly frontend router written in Rust 🦀🚀
https://github.com/arwinneil/wasm-router
rust wasm wasm-router
Last synced: 16 days ago
JSON representation
Playground for a WebAssembly frontend router written in Rust 🦀🚀
- Host: GitHub
- URL: https://github.com/arwinneil/wasm-router
- Owner: arwinneil
- License: mit
- Created: 2020-07-24T16:29:46.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-06T19:27:02.000Z (over 4 years ago)
- Last Synced: 2025-03-24T11:12:18.216Z (about 1 month ago)
- Topics: rust, wasm, wasm-router
- Language: Rust
- Homepage: https://wasm-router.netlify.app
- Size: 158 KB
- Stars: 7
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE_MIT
Awesome Lists containing this project
README
[](https://app.netlify.com/sites/wasm-router-poc/deploys)
# wasm-router 🦀🚀Playground for a WebAssembly frontend router written in Rust, live [here](https://wasm-router.netlify.app/).
## Current Status âš’
- Hybrid router combinng `hash` & `history` style routing modes, delivering clean URLs without the need to reload page
- DOM updated using Rust function pointers & [web-sys](https://crates.io/crates/web-sys)
- 404 Page if route does not exist
- Supports hooks at different stages of the routing lifecycle (WIP)## Example Usage
```rust
#[wasm_bindgen]pub fn main() {
let mut r = router::Router::new();r.add("/", update_home);
r.add("/about", update_about);
r.add_hook("on_loaded", loaded);
r.init();
}pub fn update_home(s: &str) { /* DOM Manipulation */}
pub fn update_about(s: &str) { /* DOM Manipulation */}
pub fn loaded() { /* DOM Manipulation */}```
## Building
```
wasm-pack build -t web
```