Open powellnorma opened 1 month ago
If you want a dynamic route using the static adapter, you'll have to opt into SPA-mode (fetching the data when the page is mounted). You can do this by turning off prerendering for the dynamic route and specifying a fallback page option. https://kit.svelte.dev/docs/single-page-apps#usage
Does that fit your use case?
Describe the problem
Let's say I have
item/[id]/+page.svelte
, which just contains:Now I don't know all the itemIds in advance (and it also could be millions of different ones).
What works: Klicking on a link like
<a href="./item/{Math.floor(Math.random() * 100) + 1}">Random Item</a>
from the root page.What doesn't work: Navigating to /item/123 directly - As there isn't a prerendered .html for this.
I tried serving index.html in that case, but it fails, since
In Routify this works without problems, it doesn't prerender individual pages, but expects you to always just serve the root index.html
Describe the proposed solution
Adjust the generated index.html file such that it can be served for any path.
Alternatives considered
On the backend, I currently rewrite the URL to
/?jump-to-path=<somePath>
, and in +layout.svelte I do:This works, but it flickers and requires extra code.
Importance
would make my life easier
Additional Information
In a real app,
item/[id]/+page.svelte
might fetch data dynamically via XHR. Implementing the proposed feature would make it easier to use svelte-kit without Node (e.g. when the backend is written in golang).