Skip to main content
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, login, account selection, and session management, see the Phantom Connect guide.

Connection flow

  1. Provider setup: Wrap your app with PhantomProvider and specify enabled providers.
  2. Connection: Use useConnect() or useModal() to establish wallet connection.
  3. Chain operations: Use chain-specific hooks (useSolana(), useEthereum()) for transactions and signing.

Core connection hooks

useConnect hook

Connect to wallet with an authentication provider:

Authentication providers

The connect() method accepts a provider parameter to specify how users should authenticate:

useIsExtensionInstalled hook

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:
When to use injected provider:
  • User wants to use their existing extension wallet directly.
  • No embedded wallet creation needed.
  • Direct access to extension accounts and balances.
Account change detection: When using the injected provider, the SDK automatically detects when users switch accounts in their wallet extension and updates the connection state accordingly. Your app will receive updated account information through the useAccounts() and usePhantom() hooks when account changes occur.

Core account hooks

useAccounts hook

Get connected wallet addresses:

useDisconnect hook

Disconnect from a wallet:
The SDK includes a built-in connection modal that provides a user-friendly interface for connecting to Phantom. Use the useModal() hook to control it:
Modal features:
  • Multiple sign-in options: Google, Apple, browser extension
  • Built-in error handling and loading states
  • Works across devices and environments
  • Handles the full connection flow and returns a ready-to-use wallet session
  • Presented as a bottom sheet optimized for mobile interaction

Using ConnectBox for auth callbacks

The ConnectBox component provides an inline, embedded connection experience that’s perfect for auth callback pages. Unlike the modal, it renders directly in your page flow and automatically handles all OAuth callback states.
ConnectBox component showing login options

Setting up an auth callback page

When using OAuth providers (Google, Apple), users are redirected to your callback URL after authentication. Use ConnectBox on this page to handle the callback flow:

ConnectBox props

Usage examples

ConnectBox vs modal

Best practice: Use ConnectBox on your OAuth callback page (/auth/callback) to automatically handle the authentication completion flow. The component shows loading states during token exchange and displays any errors clearly.

Configuration options

Important notes about 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 the google and apple providers.
  • Not required for the injected provider.

Handling connection errors

When a connection fails, the connect() promise rejects with an error.