#yew #routing #page #props #component #automatic #filesystem-based

yew-fs-router

Filesystem-based routing for Yew

4 releases (breaking)

0.4.0 Sep 21, 2022
0.3.0 Sep 14, 2022
0.2.0 Sep 13, 2022
0.1.0 Sep 12, 2022

#132 in #routing

MIT/Apache

4KB

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.

Dependencies

~13MB
~238K SLoC