Skip to main content
The Phantom Connect React SDK provides React hooks for connecting to existing Phantom user wallets in your React apps with native transaction support across multiple blockchains.

Quick start

Generate a new Solana project using the Phantom Embedded React Starter template.
Run the command above in your terminal to get started. View template on Solana Templates →

Features

  • Built for React: Provides React hooks (usePhantom, useModal) and a provider component for app-level configuration.
  • Multi-chain support: Solana and Ethereum with dedicated hooks.
  • Connection modal: Built-in, customizable modal for connecting users to Phantom.
  • Flexible authentication providers: OAuth (Google, Apple) and the Phantom browser extension.
  • 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, expand your app in the left navigation, then select Set Up.
    • Your App ID appears at the top of the page.
  • 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:
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 google and apple providers
  • Not required for injected provider

Installation

Dependencies

Install additional dependencies based on the networks you want to support: Example for Solana and Ethereum support:

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, browser extension) and handles all connection logic automatically.

Using the Modal with useModal Hook

To use the modal, pass a theme prop to PhantomProvider and use the useModal() hook to control visibility:
Modal features:
  • Multiple auth providers: Google, Apple, browser extension
  • Automatic provider detection: Shows browser extension option when Phantom is installed
  • 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:
ConnectButton features:
  • 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

ConnectBox component

An inline embedded component that displays the connection UI directly in your page layout (without a modal backdrop). Perfect for auth callback pages or when you want a more integrated connection experience. The component automatically handles all connection states including loading, error, and success during the auth callback flow.
ConnectBox component showing login options
Props: Usage Examples:
ConnectBox Features:
  • Inline embedded: Renders directly in page flow (not as a floating modal)
  • Auto state management: Automatically shows connection/login UI when disconnected, wallet info when connected
  • Auth callback support: Handles loading and error states during OAuth callback flows
  • No close button: Designed for embedded use cases where users shouldn’t dismiss the UI
  • Theme-aware: Uses your configured theme for consistent styling
Use ConnectBox for auth callback pages: When using OAuth providers (Google, Apple), users are redirected to your callback URL after authentication. Place ConnectBox on this page to automatically handle the auth flow completion with proper loading and error states.

Theming

The SDK includes pre-built themes and supports full customization to match your app’s design.

Pre-built themes

Use the included darkTheme or lightTheme:

Custom themes

Create a custom theme object to fully control the modal’s appearance:
The secondary color must be a hex color value (for example, #98979C) as it’s used to derive auxiliary colors with opacity.

Chain-Specific Hooks

The React SDK provides dedicated hooks for each blockchain:

useSolana hook

useEthereum hook

EVM support for Phantom Connect embedded wallets will go live later in 2026.
Supported EVM Networks:

Auto-Confirm Hook (Injected Provider Only)

The SDK provides auto-confirm functionality that allows automatic transaction confirmation for specified chains.

useAutoConfirm hook

Wallet Discovery Hook

useDiscoveredWallets

Get discovered injected wallets with automatic loading and error states. Discovers wallets using Wallet Standard (Solana) and EIP-6963 (Ethereum) standards.
Returns:

SDK Initialization

The SDK provides an isLoading state to track when initialization and autoconnect are in progress:

Debug Configuration

Configure debug logging by passing a debugConfig prop to PhantomProvider:
Debug configuration properties:

Available hooks

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

Connect modal example

Drop-in connect modal example showing the full sign-in flow

All examples

Browse all example applications on GitHub

Additional resources

SDK overview

Compare all Phantom SDKs and choose the right one

Phantom Connect

Learn about authentication flows and user experience

JWT authentication

Implement custom JWT-based authentication