diff --git a/README.md b/README.md index 19cec57..3467129 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ -# svelte-hydrated -💧 Indicating hydration status by svelte-store + + + +## Installation + +```bash +npm i svelte-hydrated +``` + +## Example + +The `$hydrated` store is updated to `true` at the next tick when the `browser` is `true` + +```svelte + + +{#if $hydrated} +

Hydrated

+{:else} +

Not Hydrated

+{/if} +``` + +## Why not use `browser` ? + +The `browser` (`$app/environment`) is useful for identifying the execution environment of the code, but its value is determined before the first rendering is started. +This means that `transition` etc. will not be triggered when hydration completes. +The `$hydrated` store is updated to `true` at the next `tick` when the browser is `true`, making it simpler to set `transition`.