Recommended: JavaScript SDK for React Native
While this SDK is still supported, we recommend using newer JavaScript SDK, which is optimized for React Native, but also comes with a host of other benefits.
Introduction
This guide will help you use the Phantom redirect-based connect feature on mobile. Instead of deeplinking into the Phantom in-app browser, your users can enjoy a redirect-based connection, where they are automatically redirected between the app and their wallet to facilitate the connect, sign and additional method calls.Why redirect events are necessary
Unlike browser-extension wallets (like MetaMask or Phantom browser extension), Phantom on mobile operates via deep links. When you request a signature:- Your app opens Phantom via a deep link (
phantom://) - User approves or rejects in the Phantom app
- Phantom redirects back to your app
- The original JavaScript execution context is lost
- Any
Promiseawaiting the signature result never resolves - Your app loses track of the pending operation
Setup
mobileExperience prop
Make sure you set mobileExperience to redirect on your DynamicContextProvider:
With just this code, your users will connect with the redirect-based approach. If you want to learn how to make method calls (like signAndSendTransaction) and access the result, read on.
Handling redirect events
When using redirect-based signing on mobile, Phantom opens via deep link and redirects back after the user approves or rejects. Because the original Promise context is lost, you must use event listeners to capture the results. In React Native, use theclient.wallets.phantom event emitter to subscribe to redirect results:
Available events
All callbacks/events are optional. The events are persisted and re-emitted when the app regains focus, ensuring you always receive the result even if the app was backgrounded.