kiliman / remix-flat-routes

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

Hybrid Routes #22

Closed stephen776 closed 1 year ago

stephen776 commented 1 year ago

Based on the conversation on the Remix Flat Routes RFC discussion - is it correct that this library supports "hybrid routes" out of the box? I do not see anything referencing this in the README.

I was attempting to use a hybrid of a "layout route" directory with normal flat route subdirectories. Does this work out of the box?

Something like this:

routes/
  _dashboard/
     _list/
        _indext.tsx
    _update/
        _index.tsx
kiliman commented 1 year ago

At the moment, hybrid routes are part of a separate branch I'm working on. I plan to have it ready for Remix Conf Europe next week.

However, looking at your routes, I don't think those are valid. You are using pathless routes (_ prefix) all the way down, so Remix won't be able to determine the correct route based on the URL. They would all match / URL.

If you got rid of the _ on all the routes, then hybrid routes should work just fine.

routes/
  dashboard/
    list/
      _index.tsx     <- /dashboard/list
    update/
      _index.tsx     <- /dashboard/update

OR simplify as

routes/
  dashboard/
    list.route.tsx    <- /dashboard/list
    update.route.tsx  <- /dashboard/update
    dashboard.css
    logo.png

The .route suffix would let you "tag" a file as a route without having to create a folder/_index.tsx file.

stephen776 commented 1 year ago

Ok awesome.. ya the _ are typo in my example. Thanks for the reply

stephen776 commented 1 year ago

Any new info on hybrid routes?

kiliman commented 1 year ago

Have you tried hybrid routes? What do you think of them?

stephen776 commented 1 year ago

Have you tried hybrid routes? What do you think of them?

Yep! Just migrated my project last night. I think it’s fantastic. Exactly what I was hoping for. Thanks for all the work you’ve done here!