Repository navigation
Replies: 1 comment 4 replies
// The route used must match the file path, otherwise `createRouter` throws an error
export default createController(routes.auth.login, {
actions: {
// ...
}
})Curious where Note Remix v1 also had file routing conventions based around nested folders, but decided to go with a flat file/folder approach for v2 due to the tedium of navigating large folder structures in non-trivial apps. My own personal opinion is that I'm not so sure this should be a first-party solution. I think any filesystem-based approach should live in user-space, allowing consumers to choose their routing conventions as fits their preference/team/project. |
Uh oh!
There was an error while loading. Please reload this page.
This proposal describes a first-party API to map routes to the router through file structure patterns.
The problem
Remix's named route definitions are excellent, but they require "manually" connecting each set of routes to the router.
Besides being repetitive, this doesn't guarantee that a set of routes is actually mapped to the router. If you forget to call
.mapfor at least one of the route leaves, they will never be accessible.File-based routing can solve this by requiring the file structure to match the
routesobject structure, ensuring that a route module exists for every route leaf in the object.Proposal
Ship a first-party
remix/router/fspackage as an optional, "plug-and-play" alternative to theremix/routerAPIs.It should offer enhanced wrappers for
createRouterandcreateController:createRoutermust accept theroutesobject and query the file structure to match the object's format;createControllermust maintain a reference to the route for identity verification. The route used must correspond to the controller's file path.Usage
Resources
packages/router.All reactions