DioxusLabs / DioxusLabs/dioxus
Support Nested/Combined Routable Enums for Modular Routing
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
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:
```rust
#[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:
```rust
#[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
```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!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.