1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! Provides routing faculties using the browser history API to build
//! Single Page Applications (SPAs) using [Yew web framework](https://yew.rs).
//!
//! # Usage
//!
//! ```rust
//! use yew::functional::*;
//! use yew::prelude::*;
//! use yew_router::prelude::*;
//!
//! #[derive(Debug, Clone, Copy, PartialEq, Routable)]
//! enum Route {
//! #[at("/")]
//! Home,
//! #[at("/secure")]
//! Secure,
//! #[not_found]
//! #[at("/404")]
//! NotFound,
//! }
//!
//! #[component(Secure)]
//! fn secure() -> Html {
//! let navigator = use_navigator().unwrap();
//!
//! let onclick_callback = Callback::from(move |_| navigator.push(&Route::Home));
//! html! {
//! <div>
//! <h1>{ "Secure" }</h1>
//! <button onclick={onclick_callback}>{ "Go Home" }</button>
//! </div>
//! }
//! }
//!
//! #[component(Main)]
//! fn app() -> Html {
//! html! {
//! <BrowserRouter>
//! <Switch<Route> render={switch} />
//! </BrowserRouter>
//! }
//! }
//!
//! fn switch(routes: Route) -> Html {
//! match routes {
//! Route::Home => html! { <h1>{ "Home" }</h1> },
//! Route::Secure => html! {
//! <Secure />
//! },
//! Route::NotFound => html! { <h1>{ "404" }</h1> },
//! }
//! }
//! ```
//!
//! # Internals
//!
//! The router registers itself as a context provider and makes location information and navigator
//! available via [`hooks`] or [`RouterScopeExt`](scope_ext::RouterScopeExt).
//!
//! # State
//!
//! The [`Location`](gloo::history::Location) API has a way to access / store state associated with
//! session history. Please consult [`location.state()`](crate::history::Location::state) for
//! detailed usage.
extern crate self as yew_router;
pub use ;
pub use ;
pub use Switch;