exportWallet method requires a secure browser context and therefore can only be executed through the React SDK. Mobile apps built with React Native, Swift, Android, or Flutter can support key export by opening a hosted web page in a WebView. The user logs in on the hosted page and exports their key.
How it works
- The user taps “Export key” (or equivalent) in the native app.
- The app opens the hosted export page URL in a WebView.
- On the hosted page, the user logs in with Privy (email, OAuth, etc.) if they are not already logged in.
- After logging in, the user taps “Export wallet” on the page, which calls
exportWallet()and shows the export modal. - When export completes (or fails), the page posts a JSON result back to the native app via a messaging bridge.
Prerequisites
- Privy integrated into the mobile app with users authenticating and embedded wallets created. See the quickstart for React Native, Swift, Android, or Flutter.
- Familiarity with exporting wallets via the React SDK.
1. Build the export web page
Create a hosted web page where the user can log in with Privy (if needed) and then tap a button to export their wallet key. The page uses the Privy React SDK and posts the result back to the native app via a messaging bridge.2. Load the WebView in the native app
When the user taps “Export key”, open the hosted export page URL in a WebView. Use incognito or non-persistent storage so that login and export data are not cached.- React Native
- Swift
- Android
- Flutter
3. Handle the export result
When the hosted page completes (or encounters an error), it posts a JSON message back to the native app. Parse this message to determine the outcome and dismiss the WebView.- React Native
- Swift
- Android
- Flutter
Security considerations
Keep the following in mind when implementing the WebView-based export flow:
- Ephemeral WebViews: Use incognito or non-persistent data store modes (shown in the examples above) so that login and export data are not cached on the device.
- Separate origin: The private key is assembled on a different origin from the app and the hosted page. Neither the app nor the page can access the full private key.

