Closed J4gQBqqR closed 3 months ago
This is the intended behavior. https://kit.svelte.dev/docs/load#universal-vs-server Universal load
functions run on both the client and the server. Among other reasons, this is so that they can return things that can't be serialized and sent over the network. In your case, this results in the app being hydrated on the client side to a different value than was rendered on the server.
I guess I am misinterpreting what it means by running on "both" sides. I was under the impression that the client side code will not repeat whatever that is already generated from the server side so as to make the rendering faster. It might be too magical for client side to "hydrate" in that fashion.
It turns out that only the REST API fetch inside of the load function is not re-run.
The feature I was imaging could possibly be the sale point of the Qwik framework.
Describe the bug
I am passing a random string through load function. I am expecting that the already generated string that I get from load function will be persistent during rendering my webpage. However, the rendered string and the one generated during SSR is different.
Reproduction
https://stackblitz.com/edit/vitejs-vite-4uijlv?file=my-app%2Fsrc%2Froutes%2F%2Bpage.svelte
Notice that the string printed in the console is different than the one showing in the webpage.
Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
I have the following questions:
PS: I tried both svelte 4 and svelte 5, both are the same.