Phantom React SDK
The Phantom React SDK provides React hooks for connecting to existing Phantom user wallets in your React 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 SDK connects to existing Phantom user wallets, ensuring:- Users control their own wallets and private keys
- Integration with Phantom’s secure wallet infrastructure
- No private key handling in your application
- User maintains full control of their assets
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.
Authentication Configuration
When using the embedded provider, you’ll need to configure authentication options:redirectUrl
:
- Must be an existing page/route in your application
- Must be whitelisted in your Phantom Portal app configuration
- This is where users will be redirected after completing OAuth with Google
Installation
Dependencies
Install additional dependencies based on the networks you want to support:Network Support | Required Dependencies |
---|---|
Solana | @solana/web3.js OR @solana/kit |
Ethereum/EVM | viem |
Quick Start
Basic Setup with Chain-Specific Operations
Chain-Specific Hooks
The React SDK provides dedicated hooks for each blockchain:useSolana Hook
useEthereum Hook
Auto-Confirm Hook (Injected Provider Only)
useAutoConfirm Hook
Available Hooks
Hook | Purpose | Returns |
---|---|---|
useConnect | Connect to wallet | { connect, isConnecting, error } |
useAccounts | Get wallet addresses | WalletAddress[] or null |
useIsExtensionInstalled | Check extension status | { isLoading, isInstalled } |
useDisconnect | Disconnect from wallet | { disconnect, isDisconnecting } |
useAutoConfirm | Auto-confirm management (injected only) | { enable, disable, status, supportedChains, ... } |
useSolana | Solana chain operations | { solana: { signMessage, signAndSendTransaction, ... } } |
useEthereum | Ethereum chain operations | { ethereum: { signPersonalMessage, sendTransaction, ... } } |