Provides routing faculties for the Yew web framework.
This crate consists of multiple types, some independently useful on their own, that are used together to facilitate routing within the Yew framework. Among them are:
- RouteService - Hooks into the History API and listens to
PopStateEvents to respond to users clicking the back/forwards buttons.
- RouteAgent - A singleton agent that owns a RouteService that provides an easy place for other components and agents to hook into it.
- Switch - A trait/derive macro that allows specification of how enums or structs can be constructed from Routes.
- Router - A component connected to the RouteAgent, and is capable of resolving Routes to Switch implementors, so you can use them to render Html.
- Route - A struct containing an the route string and state.
- RouteButton & RouteLink - Wrapper components around buttons and anchor tags respectively that allow users to change the route.
Because the History API allows you to store data along with a route string,
most types have at type parameter that allows you to specify which type is being stored.
As this behavior is uncommon, aliases using the unit type (
()) are provided to remove the
need to specify the storage type you likely aren't using.
If you want to store state using the history API, it is recommended that you generate your own
aliases using the
Give it a typename, and it will generate a module containing aliases and functions useful for
routing. If you specify your own router_state aliases and functions, you will want to disable
unit_alias feature to prevent the default
() aliases from showing up in the prelude.
This crate has some feature-flags that allow you to not include some parts in your compilation.
- "default" - Everything is included by default.
- "core" - The fully feature complete ("router", "components", "matchers"), but without unit_alias.
- "unit_alias" - If enabled, a module will be added to the route and expanded within the prelude
for aliases of Router types to their
- "router" - If enabled, the Router component and its dependent infrastructure (including "agent") will be included.
- "agent" - If enabled, the RouteAgent and its associated types will be included.
- "components" - If enabled, the accessory components will be made available.
Components that integrate with the route agent.
Module for matching route strings based on tokens generated from the yew_router_route_parser crate.
Prelude module that can be imported when working with the yew_router
Wrapper around route url string, and associated history state.
Service that interfaces with the browser to handle routing.
Parses routes into enums or structs.
Generates a module named