sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.73k stars 1.94k forks source link

In memory routes #1081

Closed cowlingj closed 3 years ago

cowlingj commented 3 years ago

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

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.

benmccann commented 3 years ago

You can load the components you want in your route to accomplish this today. You don't have to use the router to show a new component