Support Nested/Combined Routable Enums for Modular Routing
First, thank you for the great work on this project!
I’m currently implementing routing using #[derive(Routable)] and everything works well for flat route definitions. However, I ran into a limitation when trying to structure routing in a more modular way.
Right now, I have a primary route enum:
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
pub enum Route {
#[layout(Navbar)]
#[route("/")]
Home,
#[route("/blog/:id")]
Blog { id: i32 },
}
And I also want to group all admin-related pages in a separate enum:
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
pub enum AdminRoute {
#[route("/dashboard")]
Dashboard,
}
My goal is to mount AdminRoute under the main Route enum similar to how nested or child routes work in other frameworks like Vue Router, React Router, etc.
For example:
/admin/dashboard → AdminRoute::Dashboard
…and potentially something like:
```rust
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
pub enum Route {
#[layout(Navbar)]
#[route("/")]
Home,
#[route("/blog/:id")]
Blog { id: i32 },
#[nest("/admin")]
AdminRoute
#[end_nest]
}
Motivation
- Improve modularity by grouping routes by feature/domain
- Avoid one large, monolithic router enum
- Align with common routing patterns in web frameworks
- Enable layouts for entire route groups (e.g., Admin shell UI)
Proposal / Question
Is it currently possible to include a nested Routable enum inside another Routable enum?
If not, would you consider implementing support for this feature?
Even basic nesting would help route organization significantly for large apps.
Additional Notes
If there’s an existing workaround, please let me know — the documentation didn’t indicate a clear approach for this scenario.
Thanks again for the awesome project!
You can nest enums with the child attribute: https://github.com/DioxusLabs/dioxus/blob/386153672e68228eacb4b2adf9f66e02e66a3e36/packages/router/tests/via_ssr/child_outlet.rs#L19-L33. We need to add this to the router docs