-
-
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
import { hydrated } from '$app/env';
#5276
Comments
How would this behave differently from |
I assumed EDIT: I see now that it is not. Maybe the docs could specify that it is false before hydration? |
Oh, |
Yes. We find it to be a good moment to start un-hidding ui features that depend on javascript being enabled and sveltekit to be fully loaded (no more layout shifts caused by svelte-kit loading components). We basically want to mark the application as |
Also, we have a simple debug menu that shows |
SvelteKit emits a import { writable } from 'svelte/store'
let _hydrated = writable(false)
if (!import.meta.env.SSR) {
window.addEventListener('sveltekit:start', () => _hydrated.set(true), { once: true })
}
export const hydrated = { subscribe: _hydrated.subscribe } |
Hydration is synchronous — there is no 'during', only before and after. That might change in future (if we introduced some sort of non-blocking hydration) but even in that case the DOM changes would be committed synchronously. There's no version of |
Just for reference: the |
Describe the problem
I want to know when the page has been hydrated and change my UI accordingly.
Describe the proposed solution
A writable store that by default has a value of
false
, and when the page has been fully hydrated, svelte-kit sets it totrue
.Alternatives considered
Custom implementation with my own store somewhere in
$lib
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: