Expand description

Filesystem-based routing for Yew.

Simply create a src/pages/ folder and place rust source files inside it at the desired path. Each source file must expose a component called Page that will be rendered at that path. URL parameters will be passed automatically as props.

Some examples:

  • pages/index.rs will be served at /
  • pages/foo.rs will be served at /foo
  • pages/blog/index.rs will be served at /blog
  • pages/blog/[id].rs will be served at /blog/<any string> and the page component will receive an id prop of type String.
  • pages/blog/[id:u64].rs will be served at /blog/<any u64> and the page component will receive an id prop of type u64.

Typed parameters work with anything that implements FromStr. If the conversion fails, the route will not match.

TODO:

  • Implement not found handling.

Macros

Use in the root of your crate in order to include all the modules and generate the router.

Structs

Functions

Call in build.rs. Needed to make proper change detection work when a new page is created.

Type Definitions