Provide method to get all routes
See original GitHub issueWhat problem does this feature solve?
If an application is split into several Vue components/libraries, each component can add their specific routes using router.addRoutes(array). In the main application we then want to dynamically create menu items from all available routes. Currently there seems to be no way to get all routes, including those added with addRoutes().
We’ve done a workaround by importing routes manually from all included components and appending them into one array. This array is then used when constructing the router instance. It’s a lot of boilerplate and easy to miss an import. A Router.getRoutes() method would really help in this use-case.
What does the proposed API look like?
router.getRoutes()
or router.getAllRoutes()
that returns an array of route configurations.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React Router: get all routes as array
Another possible way to represent a route is to use JSX, which has a different structure itself, for example: childRoutes is represented as...
Read more >URL Dispatch
The App::route() method provides simple way of registering routes. This method adds a single route to application routing table. This method accepts a...
Read more >Routers - Django REST framework
Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. Instead of declaring separate routes for...
Read more >Express Tutorial Part 4: Routes and controllers - MDN Web Docs
The routes are defined either using .get() or .post() methods on the router object. All the paths are defined using strings (we don't...
Read more >Spring Cloud Gateway
Spring Cloud Gateway aims to provide a simple, yet effective way to route to ... The Path Route Predicate Factory takes two parameters:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It will be good to have them all in one place, as for example here:
router.options.routes
. All defined routes and all added dynamically. Can we have it somehow?Yes, this is somewhat important data to get. I did workaround for myself like
but it doesn’t work for children and same path routes.