Day 10 β a lot of you wanted a place to put asynchronous setup work that happens before your SvelteKit app starts up. You can now export an `init` function from `hooks.server.js` and `hooks.client.js` that will be awaited before any other stuff happens
π docs https://svelte.dev/docs/kit/hooks#Shared-hooks-init
π docs https://svelte.dev/docs/kit/hooks#Shared-hooks-init
Comments
To know if we are in SSR or CSR context π
π docs https://svelte.dev/docs/svelte/svelte-reactivity-window
π demo https://svelte.dev/playground/8ac86e10fdce485a99c29c95e0092df4?version=5.11.0
Yknow, the way svh and lvh should work. Except they don't in Firefox and many built-in browsers. Mayday!
(Context: https://github.com/mozilla-mobile/firefox-ios/issues/11574#issuecomment-2146095621)
@svelte.dev @rich-harris.dev
π docs https://svelte.dev/docs/kit/hooks#Universal-hooks-transport
π demo https://stackblitz.com/edit/sveltejs-kit-template-default-b5zbxomg?file=src%2Fhooks.js
also, encode/decode are shorter
π docs https://svelte.dev/docs/llms
π demo (a snake game made by Sonnet 3.5) https://svelte.dev/playground/0de3c1c1a31d47bdbb7c4aa3477a6b46
π docs https://svelte.dev/docs/svelte/imperative-component-api#unmount
π demo https://svelte.dev/playground/a4ca332691204ccd887ec7b1df818182?version=5.13.0
π docs https://svelte.dev/docs/svelte/$inspect#$inspect.trace()
π demo https://svelte.dev/playground/d135c6f00beb4fa391725e59d8061604?version=5.14.0
π docs https://svelte.dev/docs/kit/$app-state
π tutorial https://svelte.dev/tutorial/kit/page-state
The same would be nice for `+page.js` and `+layout.ts` load functions.