T
TanStack8mo ago
deep-jade

Dev-only route

Is there a declarative way to configure a TSR file-sys route as development only? I'll often keep a scratch route for prototyping, etc., and w/ RR it was straight-fwd to conditionally add the route if dev env. TSR promotes file sys routing so I'm using it but requires some other means to enable/disable the route.
5 Replies
other-emerald
other-emerald8mo ago
do you want to link to this route from non dev routes?
deep-jade
deep-jadeOP8mo ago
Hi @Manuel Schiller , no need to link to non-dev routes.
other-emerald
other-emerald8mo ago
we don't have this built-in. a workaround could be to set the route file ignore pattern depending on NODE_ENV how did you do it in RR? i am also thinking about offering some hooks in the route generator to give much more control over route generation
deep-jade
deep-jadeOP8mo ago
Thanks a bunch @Manuel Schiller -- i'll take a look at using the ignore pattern. In RR I use createBrowserRouter and setup my routes manually (my preference, but TSR advises against so I don't). Then it's just a matter of checking import.meta.env.MODE, and conditionally pushing the dev route(s) onto a RouteObject array that i hand to the root router (i.e., if mode eq 'development'.) Appreciate your getting back.
foreign-sapphire
foreign-sapphire7mo ago
But tsr.config.json config file is a plain JSON file. How would you have it based on environment?

Did you find this page helpful?