Skip to content

v6.4.0

Choose a tag to compare

@childrentime childrentime released this 25 Jun 11:47
· 90 commits to main since this release

✨ Features

Same-tab component sync for storage & cookie hooks — closes #202

Two components bound to the same key in the same tab now stay in sync. The native storage event only fires in other tabs, so previously a header and footer useColorMode (or two useCookie on the same key) never updated each other.

  • useLocalStorage / useSessionStorage (createStorage): each write re-broadcasts a custom window event that sibling instances pick up via useEventListener; cross-tab sync still rides the native storage event.
  • useCookie: same primitive — cookies fire no native event. refreshCookie stays for changes made outside the hook.
  • useColorMode / useDarkMode: inherit it for free (built on createStorage).

Notes:

  • Uses a window event (not a module-level registry) so it survives the library being bundled more than once.
  • listenToStorageChanges now gates the cross-tab listener only; same-tab sync is always on.

🐛 Fixes

  • useTimeout / useTimeoutFn no longer flash pending false → true on mount — it seeds the real armed value from immediate. Closes #203.

📖 Docs

Corrected the useCookie / useLocalStorage / useSessionStorage sync notes and added clickable two-component live demos (en + zh-Hans + zh-Hant).

Full PR: #204