PersistedStore
PersistedStore is a thin static wrapper around window.localStorage for persisting data across page reloads.
import { PersistedStore } from '@segmentify/integration';
PersistedStore.setItem('myKey', 'myValue');const value = PersistedStore.getItem('myKey'); // 'myValue'PersistedStore.removeItem('myKey');PersistedStore.clear();Storing Objects
Section titled “Storing Objects”Since localStorage only stores strings, serialize objects:
PersistedStore.setItem('user', JSON.stringify({ email: 'user@example.com' }));const parsed = JSON.parse(PersistedStore.getItem('user') || 'null');Internal Keys
Section titled “Internal Keys”The library uses PersistedStore for data that must survive page reloads:
| Key | Purpose |
|---|---|
__store:__segmentifyEventQueue__ | Events deferred with nextPage: true |
sgfUserUpdateData | Cached user identification data |
::: warning Avoid overwriting these keys — the library depends on them. :::
For how ReactiveStore and PersistedStore compare, see the comparison table in ReactiveStore.