> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle storage loss

> Detect and respond when a user's wallet signing share is no longer in device storage.

Safari's Intelligent Tracking Prevention (ITP) can clear `localStorage` after periods of inactivity. Because Portal stores the user's signing share in `localStorage`, the share may be missing the next time a user opens your app.

The SDK invokes any `onWalletNotOnDevice` listeners during initialization when it detects this has happened.

## Detecting storage loss

Register your listener as early as possible. If the event already fired before you subscribed, the callback is replayed automatically.

```typescript theme={null}
portal.onWalletNotOnDevice(async (payload) => {
  if (payload.isBackedUp) {
    // Guide the user through wallet recovery
  } else {
    // No backup exists — clear state and restart onboarding
    await portal.clearLocalWallet()
  }
})
```

The callback receives a `WalletNotOnDevicePayload`:

| Field        | Type                | Description                                         |
| ------------ | ------------------- | --------------------------------------------------- |
| `clientId`   | `string`            | The client ID of the affected wallet                |
| `isBackedUp` | `boolean`           | Whether a backup exists that can be used to recover |
| `reason`     | `'storage_cleared'` | Why the wallet is not on device                     |

* **`isBackedUp: true`** — direct the user to [recover their wallet](/sdks/web/guide/recover-a-wallet).
* **`isBackedUp: false`** — call `clearLocalWallet()` and restart the wallet creation flow.

## Next steps

* [Recover a wallet](/sdks/web/guide/recover-a-wallet) — step-by-step recovery flow to direct users to when `isBackedUp` is `true`.
* [Create a wallet](/sdks/web/guide/create-a-wallet) — restart onboarding when no backup exists.
