Svelte 4 vs 5
The data
prop
In SvelteKit, inside a +page.server
file, you can return a whole bunch of data, and inside the +page.svelte
file, you can use the data. The below example is how it works with Svelte 4.
The data
variable will be automatically typed based on the data returned from the server. The below example is how it works with Svelte 5.
The Svelte 5 example is approximately 128% (2.28x) larger than Svelte 4.
What if the data is coming from a +layout.server.ts
file and we want to use the data inside a +page.svelte
file? Svelte 4 code will stay the same, but Svelte 5 code will be.
The Svelte 5 example is approximately 302% (4x) larger than Svelte 4.
A component
Svelte 4
Svelte 5
The Svelte 5 example is approximately 631% (7.3x) larger than Svelte 4.
Reactivity in .svelte.js
/.svelte.ts
files
Svelte 4
Svelte 5
This won't work.
Do this instead:
Conclusion
This is stupid.
Constant props
In Svelte 5, you can't declare a prop as const
and another prop as let
. This is the case with Svelte 4 too.
Wrapping up
I don't fell like writing this anymore.