You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My feature request is simple, adding conditional routing. The proposal is to add two properties from the Show component into the RouteDefinition interface.
if when is not defined, use a default value that always computes to true. If the computed value of when() is false render fallback() instead of component or element.
In my opinion this allows a much cleaner syntax for creating routes that should only be available when certain conditions are met. If the conditions are not met it offers a simple way to show the end-user that some condition was not met. If fallback is not defined, treat the route as it is a 404.
The text was updated successfully, but these errors were encountered:
I think I have another use case for conditional routing. Suppose you're working on a very large web app with lots of routes. But as a developer a specific feature you want to work on only requires a small subset of those routes to get created. You only want that small subset to be built because you want your initial boot time to be snappy. How can we accomplish this with solidjs router?
Some ideas I had were:
Specify a regex ENV var (for example, PUBLIC_ROUTES_REGEX=/my/route would only generate the components for "/my" and "/my/route")
Perform a git diff to main branch and based on the components changed, only build routes for those pages that depended on those components.
Lazify all routes somehow? Assuming the app routes were defined through a team collaboration, with not all routes being defined lazy, perhaps a dev would wish to lazify all routes.
I think 2 is may be more difficult to implement than 1 but any of them may provide faster developer experience.
Perhaps if there was a hook solid-router could give us "updateRoutes" or something we could use in our vite config (or in a vite plugin) that may be ideal since we wouldn't have to mess with the commenting out code in the app. Thoughts?
My feature request is simple, adding conditional routing. The proposal is to add two properties from the
Show
component into theRouteDefinition
interface.when: () => boolean
fallback: () => JSX.Element | string | Array<JSX.Element | string>
if
when
is not defined, use a default value that always computes totrue
. If the computed value ofwhen()
isfalse
renderfallback()
instead ofcomponent
orelement
.In my opinion this allows a much cleaner syntax for creating routes that should only be available when certain conditions are met. If the conditions are not met it offers a simple way to show the end-user that some condition was not met. If
fallback
is not defined, treat the route as it is a 404.The text was updated successfully, but these errors were encountered: