kiliman / remix-flat-routes

Remix package to define routes using the flat-routes convention
MIT License
640 stars 22 forks source link

Difference with using '+'? #103

Closed vangelov closed 5 months ago

vangelov commented 5 months ago

I read the docs several times and did some tests but I still can't understand the difference between this:

parent+
├── _layout.tsx
└── child+
    └──index.tsx

and this (without + ):

parent
├── _layout.tsx
└── child
    └──index.tsx
kiliman commented 5 months ago

The + suffix is hybrid routes and is used for nesting.

Whereas folders without the + suffix is for colocation.

Hybrid routes use the following transformations:

and this (without + ):

In Remix v2 routing and remix-flat-routes you can use a folder (without +) for colocation. The folder name is your route name, and the route module is the file named: route.tsx.

Only the leaf route should have a naked folder. Instead of parent/child/route.tsx it should be parent.child/route.tsx

parent
├── _layout.tsx      => parent.tsx
└── child            => technically invalid (folder should only be on leaf route)
    └──index.tsx
parent.child         => this is correct 
├── route.tsx        => v2 convention uses `route.tsx` for route module
                        remix-flat-routes allows index, page, route, layout or anything starting with `_`
vangelov commented 5 months ago

Thank you for the detailed explanation.