Adrian Wannenmacher 4677a00adc apply clippy suggestions %!s(int64=2) %!d(string=hai) anos
..
examples 3d752e31ec add a fixed route to example %!s(int64=2) %!d(string=hai) anos
src 4677a00adc apply clippy suggestions %!s(int64=2) %!d(string=hai) anos
.gitignore e04a6d63a5 chore: move tests out of core and into the top level crate %!s(int64=3) %!d(string=hai) anos
CHANGELOG.md 56f3002aed feat: add changelogs %!s(int64=3) %!d(string=hai) anos
Cargo.toml 7d2466ff28 make hooks return a result instead of an option %!s(int64=2) %!d(string=hai) anos
Makefile.toml bd565bb65f improve Makefile tests %!s(int64=3) %!d(string=hai) anos
README.md af6362ce3e deny missing docs in router %!s(int64=2) %!d(string=hai) anos
webdriver.json ee49fc27ff fix some newlines %!s(int64=3) %!d(string=hai) anos

README.md

Dioxus Router

Dioxus Router is a first-party Router for all your Dioxus Apps. It provides a React-Router style interface that works anywhere: across the browser, SSR, and natively.

use dioxus::prelude::*;
use dioxus_router::prelude::*;

fn App(cx: Scope) -> Element {
    use_router(
        &cx,
        &|| Default::default(),
        &|| Segment::content(comp(Index)).fixed(
            "blog",
            Route::content(comp(Blog)).nested(
                Segment::content(comp(BlogList))
                    .catch_all((comp(BlogPost), BlogPost))
            )
        )
    );

    render! {
        Outlet { }
    }
}

fn Index(cx: Scope) -> Element {
    render! {
        h1 { "Index" }
        Link {
            target: "/blog",
            "Go to the blog"
        }
    }
}

fn Blog(cx: Scope) -> Element {
    render! {
        h1 { "Blog" }
        Outlet { }
    }
}

fn BlogList(cx: Scope) -> Element {
    render! {
        h2 { "List of blog posts" }
        Link {
            target: "/blog/1",
            "Blog post 1"
        }
        Link {
            target: "/blog/1",
            "Blog post 2"
        }
    }
}

fn BlogPost(cx: Scope) -> Element {
    render! {
        h2 { "Blog Post" }
    }
}

Resources

  • See the mdbook
  • See the one-page brief
  • See the guide on the doc site
  • The crates.io API