dioxus/packages/router
2022-02-04 17:18:31 +01:00
..
.vscode wip: memoize dom in the prescence of identical components 2022-01-05 00:27:22 -05:00
examples wip: memoize dom in the prescence of identical components 2022-01-05 00:27:22 -05:00
src fix: element stack not being updated properly 2022-01-31 12:29:11 -05:00
tests setup done, local tests work, check workflow 2022-02-03 00:11:38 +01:00
Cargo.toml fix some newlines 2022-02-03 09:28:06 +01:00
CHANGELOG.md feat: add changelogs 2022-01-29 10:17:14 -05:00
Makefile.toml improve Makefile tests 2022-02-04 17:18:31 +01:00
README.md feat: connect an onchange listener 2022-01-25 15:06:37 -05:00
webdriver.json fix some newlines 2022-02-03 09:28:06 +01:00

Routing for Dioxus App

DioxusRouter adds React-Router style routing to your Dioxus apps. Works in browser, SSR, and natively.

fn app() {
    cx.render(rsx! {
        Router {
            Route { to: "/", Component {} },
            Route { to: "/blog", Blog {} },
            Route { to: "/blog/:id", BlogPost {} },
        }
    })
}

Then, in your route, you can choose to parse the Route any way you want through use_route.

let id: usize = use_route(&cx).segment("id")?;

let state: CustomState = use_route(&cx).parse()?;

Adding links into your app:

Link { to: "id/{id}" }

Currently, the router is only supported in a web environment, but we plan to add 1st-party support via the context API when new renderers are available.