The official website of Mithril mentions that only one m.route call is allowed per application.
Despite this limitation, I was able to find a workaround using code splitting.
However, my application is designed to recognize only the first-level components for a given URL, making use of asynchronous code splitting to achieve this.
The challenge arises when these first-level components need to register their own namespaced routes in order to handle URL state changes for inner components. Due to the restrictions of Mithril, it is not possible to set these routes ahead of time or modify them after the initial route has been established by the wrapping component.
Adding to the complexity, each first-level component is loaded on-demand, requiring routes to be added dynamically rather than waiting for all components to load before instantiating the route.
While I appreciate the capabilities of Mithril, my specific use case presents a unique challenge that I have struggled to overcome.
In an update, I explain that my goal was to implement dynamic routing without sacrificing functionality such as variadic routing. However, it became clear that achieving this natively within Mithril was not feasible.
To address this limitation, I developed a custom router that supports dynamic and unknown routes, flexible variadic routing, improved parameter handling, and global data management across views without relying on global variables or the History API.
Although creating a pull request was suggested, it became apparent through discussions on Github that my requirements were too specialized for inclusion in the core logic of Mithril.
Despite these challenges, I remain committed to using Mithril as my preferred framework and hope that future versions, such as Mithril 2, will incorporate built-in support for dynamic routing.