Replies: 4 comments 20 replies
-
Remix already provides a way to define your own routes. The Just use the provided feature to generate your own convention. |
Beta Was this translation helpful? Give feedback.
-
You could use this https://remix.run/docs/en/v1/api/conventions#ignoredroutefiles to ignore any file inside routes without the |
Beta Was this translation helpful? Give feedback.
-
Hi @dalelotts You should take a look at the new flat routes convention, especially the nested-flat routes. This is pretty close to the layout you wanted. |
Beta Was this translation helpful? Give feedback.
-
Hi @dalelotts, In your ideal convention, where do you suggest to put the files shared across multiple routes? Components, styles, hooks, models, types, services, utilities, integrations, ... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I love that routes are defined by convention in remix! Such a wonderful innovation.
However, I really dislike the
package-by-type
layout that comes along with this convention. It requires me to put unrelated files into the same folder. For example, theroutes
folder must contain thenotes
,login
,logout
andjoin
files, but these files have nothing to do with each other, they are unassociated in every possible way, so why do they have to live together?I'd like to suggest a project structure that locates all related files (CSS, TypeScript, JavaScript, images, tests, etc) together inside the same folder while continuing to use the directory structure to define the application routing.
Can we discuss using a file naming convention - rather than known folder names - to define
routes
, et al. By convention, name the file by what it is and put it anywhere you like. The following is an example for anotes
app.This is a quick stab at a possible layout, I assume that I have missed some edge cases and the above is suboptimal.
The point is that remix can continue to determine the routes by looking for files named
*.route.{js,jsx,ts,tsx}
. Simple routes can remain the same, e.g.login.route.tsx
and more complex entities can be grouped together into a folder. Just like it does now, the path to any*.route.{js,jsx,ts,tsx}
is used to determine the routes for the app. Any folder that does not contain a*.route.tsx
is not participating in routing.Related changes to
remix.config.js
would allow the developer the freedom to group their code however they like. If they like grouping by type (as it is now) the following config will work - this would be the default config so this is not a breaking change.and if the developer prefers something like the suggestion above, the following config could be used:
Beta Was this translation helpful? Give feedback.
All reactions