Hi guys, I wanted to know the community's thoughts on named routes on the frontend frameworks instead of the file system routing (like on NextJS or Nuxt).
For those who are unaware, named routes is a common feature on backend frameworks (eg. Laravel, express), where you statically declare the routes, assign a name & have a specific handler for it. File based routing generates the app's route based on the files present in a designated folder (ie /pages
)
Personally, I think named routes is a much better development experience than file-based routing. My thoughts:
-
Consistent route generation tooling through named patterns. Eg.
- declare the route:
route('/', 'home:index')
- Then, when generating the URL, you can:
route('home:index')
- declare the route:
You don't manage URL strings directly, control is abstracted for query or parameter replacement.
Clear view of the routes available to the app
Extensible to other route-based logic inside the app (middleware & layout generation, etc)
Not sure if this has been discussed, but would like to know your thoughts whether you agree to the same reasoning or have different opinion about this. Cheers
Top comments (0)