Is your feature request related to a problem? Please describe.
File based routing used by SvelteKit makes it really easy to visualise a sites structure while developing, that being said if a developer wanted part (or all) of a website to be under a single path whist still being able to nest files, they couldn't make use of SvelteKit's router. As a concrete example, let's imagine a /settings page with sub pages /settings/profile and /settings/notifications, thanks to the separation it's easy enough to break down what the different pages are for, but if we wanted all of the settings to be under the path /settings we would be out of luck.
Describe the solution you'd like
A $memoryRoutes sub folder in each route folder could exist, and when navigating to a page in one of these folders the url would remain the same as the parent route.
/account -> /settings/$memoryRoutes/profile = /settings/settings -> /settings/$memoryRoutes/profile = /settings/settings/$memoryRoutes/profile -> /settings/$memoryRoutes/notifications = /settings/settings/$memoryRoutes/profile -> /settings/payment = /settings/payment/settings/$memoryRoutes/profile -> /account = /account
Describe alternatives you've considered
Instead a const like memory = true could be exported from the parent route (i.e. /settings/index.js) to indicate that all sub routes should be in memory, this does mean that in memory and "real" routes can't be mixed and matched.
Another alternative could include an exported const path that would equal the actual path the route should be available as (so /settings/profile would export a path of /settings). This const may also need to handle dynamic params and could perhaps do so by using the same param names (/products/[id] could export /[id]).
How important is this feature to you?
This kind of thing is currently possible by disabling the router on a page that has links to in memory routes and instead use a different router with support for in memory routes, although (at least to me) this feels a little backwards.
Additional context
There might be a similar case for hash based routing like this too, but I've not really looked into it.
Is your feature request related to a problem? Please describe. File based routing used by SvelteKit makes it really easy to visualise a sites structure while developing, that being said if a developer wanted part (or all) of a website to be under a single path whist still being able to nest files, they couldn't make use of SvelteKit's router. As a concrete example, let's imagine a
/settings
page with sub pages/settings/profile
and/settings/notifications
, thanks to the separation it's easy enough to break down what the different pages are for, but if we wanted all of the settings to be under the path/settings
we would be out of luck.Describe the solution you'd like A
$memoryRoutes
sub folder in each route folder could exist, and when navigating to a page in one of these folders the url would remain the same as the parent route./account -> /settings/$memoryRoutes/profile = /settings
/settings -> /settings/$memoryRoutes/profile = /settings
/settings/$memoryRoutes/profile -> /settings/$memoryRoutes/notifications = /settings
/settings/$memoryRoutes/profile -> /settings/payment = /settings/payment
/settings/$memoryRoutes/profile -> /account = /account
Describe alternatives you've considered
memory = true
could be exported from the parent route (i.e./settings/index.js
) to indicate that all sub routes should be in memory, this does mean that in memory and "real" routes can't be mixed and matched.path
that would equal the actual path the route should be available as (so/settings/profile
would export a path of/settings
). This const may also need to handle dynamic params and could perhaps do so by using the same param names (/products/[id]
could export/[id]
).How important is this feature to you? This kind of thing is currently possible by disabling the router on a page that has links to in memory routes and instead use a different router with support for in memory routes, although (at least to me) this feels a little backwards.
Additional context There might be a similar case for hash based routing like this too, but I've not really looked into it.