You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/utils/storage/createLocalStorage.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# createLocalStorage
2
2
3
-
Create a storage instance backed by `localStorage`. Values persist across page reloads and are synced across tabs via the `storage` event.
3
+
Create a storage instance backed by `globalThis.localStorage`. Values persist across page reloads and are synced across tabs via the `storage` event when available.
Copy file name to clipboardExpand all lines: packages/docs/utils/storage/createUrlSearchParamsInHashStorage.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
Create a storage instance backed by URL hash params (`#key=value`). Useful for client-side state that shouldn't be sent to the server, like tab selection or UI mode.
4
4
5
+
This storage is browser-only: it requires `window.location` and `window.history`. In non-browser environments, it falls back to a no-op provider.
6
+
5
7
By default, changes use `replaceState` to avoid polluting browser history. Use `{ push: true }` to create history entries instead.
For URL-based providers, factory functions allow customizing the history behavior:
16
+
For URL-based providers, factory functions allow customizing the history behavior. These providers are only active in a browser context with `window.location` and `window.history`; outside the browser they fall back to a no-op provider.
Providers can declare a `syncEvent` string to indicate which DOM event should trigger re-reading values for subscribed keys. When set, `createStorage` will automatically listen to this event on `window` and notify subscribers.
80
80
81
81
-`'storage'` — for cross-tab sync (`localStorage`)
82
-
-`'popstate'` — for back/forward navigation (URL search params)
83
-
-`'hashchange'` — for hash changes (URL hash params)
82
+
-`'popstate'` — for back/forward navigation (URL search params, browser-only)
83
+
-`'hashchange'` — for hash changes (URL hash params, browser-only)
84
84
- Any custom event name
85
85
-`undefined` — no automatic sync (used by `sessionStorageProvider`)
0 commit comments