-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add named routes #61
Comments
Yeah I've used this approach in the past in older routers I've written. The only thing is then I think |
Im a huge fan of this idea. Been using it for years in Ember.js and can say, it's a blessing when it comes to paths changing. What do you think about such a Link interface? <Link name="users.user" params={{ id: 1 }} queryParams={{ source: "home" }} /> |
Any plans on working on this feature? If I can find any time I might try and work on this issue. |
Forward it! |
This looks a bit like an anti-pattern to me, now there's an invisible implicit link between the path of the route and the name of the route, like you can hypothetically name your /users route "user" and your /user route "users". For things not to break a better approach IMO is to have a single source of truth, i.e. there should probably be some objects exporting these paths, which can then be referenced both in the router and in links. |
Not really, it creates an explicit link between them in one place and you can always go to your route definition and check it out. Anyway, there's a good practice to keep your names in some enum/object and use them instead of magic strings, which is better IMO.
With named routes your single source of truth is the name of your route in case you've decided to use them instead of plain paths. The main advantage with named route is that you can control what route you're targeting in instead of letting the router decide for you. @ryansolid What your thoughts on this limitation are? |
The official router for Vue.js has a feature called "Named routes". It makes it possible to give the routes a separate name to refer to them instead of using the actual route. The benefit of this is that you can rename the route inside the config file but not where it has been referenced.
This feature would be a great addition.
The text was updated successfully, but these errors were encountered: