Skip to main content
This guide is for advanced users who want to customize how wallet authorization details are cached and persisted. If you’re using MobileWalletProvider with the default settings, authorization caching is already handled for you with AsyncStorage.

Overview

When a user authorizes your dApp with their wallet via MWA, the session returns an auth_token and account details. By caching these details, your app can stay “connected” across app restarts without prompting the user to re-authorize every time. The MobileWalletProvider from @wallet-ui/react-native-web3js handles this automatically with a built-in AsyncStorage cache. You can swap in your own cache implementation (e.g for encrypted storage) by passing a custom cache prop.

The Cache interface

The cache prop on MobileWalletProvider accepts any object that implements the Cache<T> interface:
  • get() — Retrieves the cached authorization on app startup.
  • set(value) — Stores the authorization after the user authorizes.
  • clear() — Removes cached authorization on disconnect/deauthorize.

Default: AsyncStorage

By default, MobileWalletProvider uses @react-native-async-storage/async-storage to persist authorization data. You don’t need to configure anything for this to work:

Custom cache: expo-secure-store

If you want to store authorization details in encrypted storage (e.g for sensitive auth tokens), you can create a custom cache using expo-secure-store.

Install expo-secure-store

Create a Secure Store cache

The cacheReviver function is needed to properly deserialize PublicKey objects from the cached JSON string.

Pass it to MobileWalletProvider


Using the bare MWA library

If you’re using the lower-level @solana-mobile/mobile-wallet-adapter-protocol-web3js library directly (without MobileWalletProvider), you’ll need to manage authorization caching yourself.

Check for cached authorization

When the dApp boots up, check the cache for a prior authorization:

Cache on authorize

Cache the authorization details when the user completes an authorize request:

Clear cache on deauthorize

When the user disconnects, invalidate the cache:
Last modified on July 21, 2026