True SPA mode
See original GitHub issueWe now have the ssr: false
option which gives us something close to SPA mode: https://kit.svelte.dev/docs#ssr-and-javascript
It doesn’t get us all the way there though, because in a typical SPA you would likely want to generate a single fallback page that handles all requests — for example Surge lets you add a 200.html file, while Netlify allows you to add something like this to _redirects
:
/* /200.html 200
By contrast, SvelteKit expects to generate (whether at runtime or prerender time) an HTML page that includes no content, but does include information about the route that should be hydrated, since the router isn’t invoked on load. To create a true SPA, SvelteKit needs to create a content-less file that doesn’t contain any route information, and the router needs to figure out what JS to load and execute.
I’m not certain how best to do this in a provider-agnostic way.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:81
- Comments:40 (26 by maintainers)
Top GitHub Comments
I know maintainers hate comments like, “I have this problem too”, but I couldn’t resist explaining why this is a very important use case for us.
We build self-contained apps using Go and when releasing versions of these apps we embed the files to be served from the binary’s embedded file system. Lacking a true SPA mode is what’s keeping us from exploring SvelteKit for these sort of deployment scenarios. When we embed the frontend app files, the client has to handle all routing because there is no SSR component.
As an alternative to having an SPA mode we’ve experimented with SSR using things like v8 bindings in Go but have found that the overhead isn’t worth the gain for the purpose of the application, especially since SEO isn’t a concern.
Implemented — docs here: https://github.com/sveltejs/kit/tree/master/packages/adapter-static