# PersistedStore

> PersistedStore is a thin static wrapper around window.localStorage for persisting data across page reloads.

## Usage

```typescript
import { PersistedStore } from '@segmentify/integration';

PersistedStore.setItem('myKey', 'myValue');
const value = PersistedStore.getItem('myKey'); // 'myValue'
PersistedStore.removeItem('myKey');
PersistedStore.clear();
```

## Storing Objects

Since `localStorage` only stores strings, serialize objects:

```typescript
PersistedStore.setItem('user', JSON.stringify({ email: 'user@example.com' }));
const parsed = JSON.parse(PersistedStore.getItem('user') || 'null');
```

## 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](/08-reactive-store#reactivestore-vs-persistedstore).

## See Also

- [ReactiveStore](/08-reactive-store)
