Connecting to Phantom Wallets
The React SDK follows a clear connection pattern using hooks for wallet connection and chain-specific operations.Learn about Phantom Connect: For details about authentication flows, OAuth login, extension login, account selection, and session management, see the Phantom Connect guide.
Connection Flow
- Provider Setup: Wrap your app with
PhantomProvider - Connection: Use
useConnect()to establish wallet connection - Chain Operations: Use chain-specific hooks (
useSolana(),useEthereum()) for transactions and signing
Core Connection Hooks
useConnect
Connect to wallet with an authentication provider:Authentication Providers
Theconnect() method accepts a provider parameter to specify how users should authenticate:
useIsPhantomLoginAvailable
The"phantom" provider option allows users to authenticate an embedded wallet using their existing Phantom browser extension. Use the useIsPhantomLoginAvailable hook to check if this option is available:
- Faster authentication for existing Phantom users
- No need to create a new account
- Familiar Phantom interface
- Same security and permission controls
useIsExtensionInstalled
The"injected" provider directly connects to the user’s Phantom browser extension (not an embedded wallet). Use the useIsExtensionInstalled hook to check if the extension is installed:
- User wants to use their existing extension wallet directly
- No embedded wallet creation needed
- Direct access to extension accounts and balances
Core Account Hooks
useAccounts
Get connected wallet addresses:useDisconnect
Disconnect from wallet:Configuration Options
Important notes aboutredirectUrl (for embedded provider):
- 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
PhantomProvider: