Should Qwik automatically persist useStore state across page reloads?
0 reputation · 07 May 2024, 22:56 UTC
Qwik serializes component state from the useStore hook into DOM attributes during hydration, allowing the UI to reconstruct its previous state without re‑executing side‑effects. The goal is to decide whether this serialized state should be automatically persisted to a durable storage mechanism (e.g., localStorage or IndexedDB) so that a full page reload does not reset the state.
In Qwik 1.x, the state stored in attributes is lost on reload unless the developer manually saves it elsewhere, which adds boilerplate and risks inconsistency. Persisting automatically could improve user experience but may increase HTML size, introduce storage overhead, and complicate serialization logic for large stores. Considering these trade‑offs, what should the default behavior be?
- Should Qwik provide an opt‑in flag to persist
useStorestate to localStorage after each hydration? - What performance impact would automatic persistence have on page load time and memory usage?
- How would automatic persistence interact with server‑side rendering and the existing hydration process?