File based routing more default file name options for code splitting and generation #4097
ViewableGravy
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I honestly just assume I am blind and someone has suggested this before, so sorry in advance if this is a duplciate.
At the moment, there are essentially four file names that have a meaning in tanstack router:
route.ts(x)
index.ts(x)
route.lazy.ts(x)
index.lazy.ts(x)
Index
producing the direct route (no outlet), androute
producing a layout route (outlet).It seems intuitive to me, that this idea would be extended to support the following route file naming, since components do not dictate the type of the router:
index.pending.ts
&route.pending.ts
index.error.ts
&route.error.ts
index.component.ts
&route.component.ts
These would be files that contains the pending, error and component components for their respective routes, and would automatically have a template simliar to the below
In cases where we have an extremely long loader function, or a lot of search schema logic, the route component file can become quite large. Sometimes reaching over 100 lines of just
createFileRoute
. At least in our code base, we try to aim to keep components and files under 100 lines where possible, so it seems obvious at that point that we'd want to abstract the components to another file. While this is completely doable, and we can easily name our files-index.pending.ts
or even create a custom ignore rule for these files from the autogeneration - this actually seems like something that tanstack router would want to target.I'm not a huge user of NextJS, but my understanding is they have something similar in their routing system, so it may also make the transition across easier for people if these options existed.
Beta Was this translation helpful? Give feedback.
All reactions