This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
yew_router_macro

Derive Macro Routable

Source
#[derive(Routable)]
{
    // Attributes available to this derive:
    #[at]
    #[not_found]
}
Expand description

Derive macro used to mark an enum as Routable.

This macro can only be used on enums. Every varient of the macro needs to be marked with the at attribute to specify the URL of the route. It generates an implementation of yew_router::Routable trait and consts for the routes passed which are used with Route component.

ยงExample

#[derive(Debug, Clone, Copy, PartialEq, Routable)]
enum Routes {
    #[at("/")]
    Home,
    #[at("/secure")]
    Secure,
    #[at("/404")]
    NotFound,
}