-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace hydrate
and router
options with csr
#6436
Comments
I must say I kinda liked the idea of being able to make a website without client-side routing that still has JS interactions, but I do understand the technical complications this entails, so its probably for the better! This is an orthogonal problem, but it would also be nice to be able to disable hydration and re-enable it further down the tree (e.g.: I don't want any js on the page except for a modal component). I realize this is probably more of a Svelte thing than Sveltekit though. Is this something we can expect in the future? |
So you want every navigation to be a native navigation? This would be possible with #790 (comment) |
@dummdidumm Yes, the behavior would be the same, but Sveltekit would load the whole router code even if totally unused. |
The router code, when disentangled from the rest of the SvelteKit client runtime, weighs somewhere in the region of 1.5kb plus the size of the route manifest (which is less than 3kb for an app with 200 routes, and much smaller for most apps), unless you were to include |
Fair enough! i thought it was bigger than that. |
Describe the problem
At present, there are four 'page options' —
prerender
,hydrate
,router
andssr
. As of #6197, these can be set in+layout[.server].js
files as well as+page[.server].js
files, which allows us to get rid of the corresponding config options.router
is an anomaly, however. It's the only option that has a meaning after the initial render — if you navigate to a page withrouter = false
, it will disable the client-side router altogether. There's no getting around it: this is a deeply weird option that basically no-one needs (to understand why it was introduced in the first place, see #6197 (comment)).As of #790 (comment), we'll have a much more sensible approach for disabling the router —
data-sveltekit-reload
applied to a top-level element. This would mean we can get rid of therouter
page option altogether.This does leave a gap though — right now, if
hydrate
androuter
are bothfalse
, we don't send any JavaScript with the page at all.Describe the proposed solution
We merge
hydrate
androuter
into a singlecsr
option that controls whether client-side rendering/routing takes place. (It's convenient that the acronym works for both.) Ifcsr
isfalse
, no JS is sent with the page.Strictly speaking, this is less flexible than what we have now, but having one-but-not-both be
true
is both kinda useless and currently buggy. This approach would be much simpler, both in implementation and communication —prerender
,ssr
andcsr
are a much more logical trio.Alternatives considered
Keep the current semantics of
hydrate
and always include the client-side router.Importance
would make my life easier
Additional Information
I'm raising this here as an issue rather than a discussion because I expect approximately three people to be affected by this change.
The text was updated successfully, but these errors were encountered: