2 ms·
File-based routing is fundamentally flawed and it cannot be fixed. A number of libraries opt for it since it's easier for newcomers to pick up, but eventually y
by Etheryte 1y ago
File-based routing is fundamentally flawed and it cannot be fixed. A number of libraries opt for it since it's easier for newcomers to pick up, but eventually you run into all of the cases where you do need something else. This in turn leads you to a hybrid system of multiple things where there's no single source of truth and everything is spaghetti.
- epolanski 1y agoCare to make quite a simple example where file based routing would struggle?
- Etheryte 1y agoRole based access control is one of the simplest examples, your routes need to be conditional and all come with related metadata for permissions and such. With file-based routing you'll then end up with your routes defined in one place and the configuration for them either in a separate different place or split up across the codebase. Whenever you need to change something you need to remember to do it everywhere else. If your routing is in code, you can define everything in one place with strict type checks, tests, and so on.
- array_key_first 1y agoFile-based routing makes sense for some systems, particularly CMS, where the content is files and that drives the navigation. But this is a more website thing, not an app thing, and many things want to be apps, not websites.