RFC: Add support for pathless layout routes

This issue has been tracked since 2023-01-31.

Which scope/s are relevant/related to the feature request?

router

Information

This feature can be useful to group related pages into the same folder without adding additional segments to the URL.

For the following structure:

app
  /routes
    /(auth)
       login.ts
       signup.ts

we'll be able to access the login and signup pages by using /login and /signup URLs. In the same way, we should be able to define a layout/shell component for pages in the (auth) folder:

app
  /routes
    /(auth)
       login.ts
       signup.ts
    (auth).ts

Pathless layout routes in Remix: https://remix.run/docs/en/v1/guides/routing#pathless-layout-routes

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
brandonroberts wrote this answer on 2023-01-31

I think its a good idea to support this. Was also thinking about supporting a folder that can be co-located in the routes folder but not be picked up as a route, such as _route. I don't think it would conflict with this though

goetzrobin wrote this answer on 2023-02-27

@brandonroberts I actually ran into this today. I was trying to put components that were only used in a specific route in the same folder as the route. Similar to what you describe or what the Remix docs describe here: https://remix.run/docs/en/v1/file-conventions/route-files-v2#folders-for-organization
I would absolutely this as a new feature!

goetzrobin wrote this answer on 2023-02-27

@brandonroberts are you planning on creating an RFC for hiding co-located in the routes folders? Or even better, are you already working on adding this feature?

markostanimirovic wrote this answer on 2023-02-27

I updated the issue description - instead of two underscores (/__auth), we can use round brackets /(auth) for consistency because we already support this syntax for pathless routes. Thoughts? 👀

cc @brandonroberts

brandonroberts wrote this answer on 2023-02-27

@goetzrobin I haven't but I'll create one for the ability to co-locate files within the routes folder. You're welcome to create one also if you already have a use case.

brandonroberts wrote this answer on 2023-02-27

@markostanimirovic I like it for the consistency. My other thought is it might be confusing if we want to support aux routes in the future that use the parenthesis in the URL.

We could probably define those as /path(outlet-name) with /(path) being used for pathless routes.

markostanimirovic wrote this answer on 2023-02-27

@markostanimirovic I like it for the consistency. My other thought is it might be confusing if we want to support aux routes in the future that use the parenthesis in the URL.

In case we want to support auxiliary routes, it may make sense to do a breaking change and use the __ prefix instead of brackets for all pathless routes.

brandonroberts wrote this answer on 2023-02-27

@markostanimirovic I like it for the consistency. My other thought is it might be confusing if we want to support aux routes in the future that use the parenthesis in the URL.

In case we want to support auxiliary routes, it may make sense to do a breaking change and use the __ prefix instead of brackets for all pathless routes.

You're saying define pathless routes as __index.ts instead of index.ts or (index.ts)?

I'd prefer to keep those as is and come up with a different convention for aux routes as they are much more niche in terms of usage.

markostanimirovic wrote this answer on 2023-02-27

You're saying define pathless routes as __index.ts instead of index.ts or (index.ts)?

Actually index.ts would remain the same and named pathless routes would change - (home).ts -> __home.ts.

I'd prefer to keep those as is and come up with a different convention for aux routes as they are much more niche in terms of usage.

Agree. 💯

More Details About Repo
Owner Name analogjs
Repo Name analog
Full Name analogjs/analog
Language TypeScript
Created Date 2022-07-06
Updated Date 2023-03-28
Star Count 885
Watcher Count 18
Fork Count 67
Issue Count 33

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date