Features
- Built for React: Provides React hooks (
usePhantom,useModal) and a provider component for app-level configuration. - Multi-chain support: Solana (available now), other chains coming soon.
- Connection modal: Built-in, customizable modal for connecting users to Phantom.
- Flexible authentication providers: OAuth (Google, Apple), Phantom extension, embedded wallets, and injected providers.
- User wallet integration: Connects to existing Phantom user wallets using Phantom Connect.
- TypeScript support: Fully typed API surface.
Security
The Phantom Connect 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 app: Sign up or log in to the Phantom Portal and register your app.
- Obtain your App ID:
- In Phantom 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.
- Allowlist your domains and redirect URLs: Add your app’s domains and redirect URLs in the Phantom Portal to enable wallet connections.
Authentication configuration
When using OAuth providers (google, apple), 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 authentication
- Required for google and apple providers
- Not required for phantom provider (uses extension for auth) or injected provider
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
Connection Modal
The SDK includes a built-in connection modal UI that provides a user-friendly interface for connecting to Phantom. The modal supports multiple connection methods (Google, Apple, Phantom Login, browser extension) and handles all connection logic automatically.Using the Modal with useModal Hook
To use the modal, pass atheme prop to PhantomProvider and use the useModal() hook to control visibility:
- Multiple Auth Providers: Google, Apple, Phantom Login, browser extension
- Automatic Provider Detection: Shows browser extension option when Phantom is installed
- Mobile Support: Displays deeplink option for Phantom mobile app on mobile devices
- Error Handling: Clear error messages displayed in the modal
- Loading States: Visual feedback during connection attempts
- Responsive Design: Optimized for both mobile and desktop
ConnectButton Component
A ready-to-use button component that handles the complete connection flow:- When disconnected: Opens connection modal with auth provider options
- When connected: Displays truncated address and opens wallet management modal
- Uses theme styling for consistent appearance
Theming
The SDK includes pre-built themes and supports full customization to match your app’s design.Pre-built themes
Use the includeddarkTheme or lightTheme:
Custom themes
Create a custom theme object to fully control the modal’s appearance:| Property | Description | Example |
|---|---|---|
background | Modal background color | "#1a1a1a" |
text | Primary text color | "#ffffff" |
secondary | Secondary text, borders, and dividers | "#98979C" |
brand | Brand/primary action color | "#ab9ff2" |
error | Error state color | "#ff4444" |
success | Success state color | "#00ff00" |
borderRadius | Border radius for buttons and modal | "16px" |
overlay | Modal overlay background (supports opacity) | "rgba(0, 0, 0, 0.8)" |
Chain-Specific Hooks
The React SDK provides dedicated hooks for each blockchain:useSolana hook
useEthereum hook
| Network | Chain ID | Usage |
|---|---|---|
| Ethereum Mainnet | 1 | ethereum.switchChain(1) |
| Ethereum Sepolia | 11155111 | ethereum.switchChain(11155111) |
| Polygon Mainnet | 137 | ethereum.switchChain(137) |
| Polygon Amoy | 80002 | ethereum.switchChain(80002) |
| Base Mainnet | 8453 | ethereum.switchChain(8453) |
| Base Sepolia | 84532 | ethereum.switchChain(84532) |
| Arbitrum One | 42161 | ethereum.switchChain(42161) |
| Arbitrum Sepolia | 421614 | ethereum.switchChain(421614) |
| Monad Mainnet | 143 | ethereum.switchChain(143) |
| Monad Testnet | 10143 | ethereum.switchChain(10143) |
Auto-Confirm Hook (Injected Provider Only)
The SDK provides auto-confirm functionality that allows automatic transaction confirmation for specified chains.useAutoConfirm hook
Available hooks
| Hook | Purpose | Returns |
|---|---|---|
useModal | Control the connection modal | { open, close, isOpened } |
usePhantom | Access wallet/user state | { isConnected, user, wallet } |
useConnect | Connect to wallet | { connect, isConnecting, error } |
useModal | Control connection modal | { open, close, isOpened } |
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, ... } } |
What you can do
Connect to wallets
Learn how to connect to Phantom user wallets with React hooks
Sign messages
Implement message signing for authentication and verification
Sign and send transactions
Handle transaction signing and broadcasting across blockchains
Starter kits and examples
Get started quickly with production-ready React templates:React SDK demo app
Full-featured React example with wallet connection, signing, and transactions
Next.js example
Complete Next.js integration with Phantom React SDK
Wagmi Integration
Use Phantom SDK alongside Wagmi for enhanced Ethereum support
All examples
Browse all example applications on GitHub