Skip to content

Playground for a WebAssembly frontend router written in Rust πŸ¦€πŸš€

License

Notifications You must be signed in to change notification settings

arwinneil/wasm-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Netlify Status

wasm-router πŸ¦€πŸš€

Playground for a WebAssembly frontend router written in Rust, live here.

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
  • 404 Page if route does not exist
  • Supports hooks at different stages of the routing lifecycle (WIP)

Example Usage

#[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

About

Playground for a WebAssembly frontend router written in Rust πŸ¦€πŸš€

Topics

Resources

License

Stars

Watchers

Forks