dioxus/packages/router
Dave Rolsky e22ba5b1e5 Add title prop to Link
Every element can have a title, but it's particularly useful on links, so I
think making it an explicit option is worthwhile.
2022-01-13 12:21:06 -06: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 Add title prop to Link 2022-01-13 12:21:06 -06:00
Cargo.toml Release dioxus-core v0.1.7, dioxus-core-macro v0.1.6, dioxus-html v0.1.4, dioxus-desktop v0.1.5, dioxus-hooks v0.1.6, dioxus-mobile v0.0.3, dioxus-router v0.1.0, dioxus-ssr v0.1.2, dioxus-web v0.0.4, dioxus v0.1.7 2022-01-08 02:25:03 -05:00
CHANGELOG.md Release dioxus-hooks v0.1.6, dioxus-mobile v0.0.3, dioxus-router v0.1.0, dioxus-ssr v0.1.2, dioxus-web v0.0.4, dioxus v0.1.7 2022-01-08 02:30:37 -05:00
README.md wip: memoize dom in the prescence of identical components 2022-01-05 00:27:22 -05: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! {
        Routes {
            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).path("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.