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. MobileWalletProvider 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.
AsyncStorage is unencrypted. The default cache holds the auth_token and account details in plain text, readable by anyone with access to the device filesystem or a device backup. For production apps, back the cache with encrypted storage — see Custom cache: expo-secure-store below.
Both Wallet UI packages expose the same cache prop — use the tab for the one you installed. See Installation if you haven’t picked one yet.

The Cache interface

The cache prop on MobileWalletProvider accepts any object that implements the Cache<T> interface, where T is the WalletAuthorization type exported by your Wallet UI package:
  • 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

Cached accounts hold their address as a plain string, so the cache is a straight JSON.stringify / JSON.parse round trip.

Pass it to MobileWalletProvider


Using the bare MWA library

If you’re using the lower-level MWA protocol library directly (without MobileWalletProvider), you’ll need to manage authorization caching yourself. The example below uses the @solana/web3.js wrapper; with the @solana/kit wrapper, cache account.address as a plain address string and drop the PublicKey conversions.

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 September 9, 2026