Phantom React Native SDK
The Phantom React Native SDK provides React hooks for connecting to existing Phantom user wallets in your mobile React Native applications with native transaction support across multiple blockchains.Features
- Framework Agnostic: Works with vanilla JavaScript/TypeScript and any web framework
- Multi-Chain Support: Solana (available now); Ethereum, Bitcoin, and Sui networks (coming soon)
- Native Transaction Support: Direct transaction object handling
- User Wallet Integration: Connect to existing Phantom user wallets
- TypeScript Support: Full TypeScript definitions included
Security
The React Native SDK connects to existing Phantom user wallets with secure authentication:- OAuth authentication with Google, Apple, or custom JWT providers
- PKCE support for secure OAuth flows
- User maintains full control of their existing wallets
- Integration with Phantom’s secure infrastructure
Prerequisites
- Register your application
Sign up or log in to the Phantom Portal and register your application. - Obtain your App ID
- In the Portal, go to your app and open URL Config (left-hand menu).
- This page shows your allowed origins and redirect URLs.
- Scroll down to the App ID section at the bottom of the page — your App ID is listed there, below the URL configurations.
- Copy the App ID for use in your integration.
- Whitelist your domains and redirect URLs
- Add your application’s domains and redirect URLs in the Phantom Portal to enable wallet connections.
Installation
Install peer dependencies
Required Polyfill
You must polyfill random byte generation to ensure cryptographic operations work properly. Add this import at the very top of your app’s entry point (before any other imports):⚠️ Important: The polyfill import must be the first import in your application entry point to ensure proper initialization of cryptographic functions.
Configure your app scheme
For Expo projects
Add your custom scheme toapp.json
:
Quick Start
Set up the provider
Wrap your app withPhantomProvider
:
Use hooks in your components
Hooks
useConnect
Manages wallet connection functionality.useAccounts
Provides access to connected wallet information.useSolana
Provides access to Solana-specific operations.useEthereum
Provides access to Ethereum-specific operations.useDisconnect
Manages wallet disconnection.Authentication Flows
Authentication Process
- User taps “Connect Wallet” in your app
- System browser opens (Safari on iOS, Chrome Custom Tab on Android)
- User authenticates with their chosen provider
- Browser redirects back to your app using the custom scheme
- SDK automatically processes the authentication result
- Wallet is connected and ready to use
Deep Link Handling
The SDK automatically handles deep link redirects. Ensure your app’s URL scheme is properly configured: Redirect URL format:{scheme}://phantom-auth-callback?wallet_id=...&session_id=...
Security Features
Secure Storage
- iOS: Uses Keychain Services with hardware security
- Android: Uses Android Keystore with hardware-backed keys
Authentication Security
- System Browser: Uses secure system browsers, not in-app webviews
- Origin Verification: Automatic verification of redirect origins