A comprehensive suite of SDKs for integrating Phantom Wallet across different platforms and use cases, supporting both Phantom browser extension and embedded non-custodial wallets.
- React SDK - React hooks and components
- Browser SDK - Vanilla JavaScript/TypeScript
- React Native SDK - Mobile app integration
- @phantom/wallet-sdk -
⚠️ DEPRECATED - Use @phantom/browser-sdk or @phantom/react-sdk instead (NPM)
All frontend SDKs support multiple authentication providers that you can configure via the providers array:
Connect to the user's existing Phantom browser extension wallet:
- Uses wallets already installed and funded by the user
- Requires Phantom browser extension to be installed
- Access to user's existing wallet history and assets
- No
appIdrequired
Create or use non-custodial embedded wallets within your application:
"google"- Google OAuth authentication"apple"- Apple ID authentication"phantom"- Phantom Login authentication"x"- X (Twitter) authentication"tiktok"- TikTok authentication
Embedded providers create:
- App Wallet: Fresh wallet created per application (unfunded, app-specific)
- User Wallet: User's Phantom wallet accessed via authentication (potentially funded, portable across apps)
All embedded providers require an appId from phantom.com/portal
This repository contains multiple SDKs for different integration needs, prioritized by ease of use:
@phantom/react-sdk - React hooks and components for Phantom integration with built-in UI components.
import {
PhantomProvider,
ConnectButton,
usePhantom,
useSolana,
useEthereum,
AddressType,
darkTheme,
lightTheme,
} from "@phantom/react-sdk";
// App wrapper with provider and theme configuration
<PhantomProvider
config={{
providers: ["google", "apple", "phantom", "injected"], // Allowed auth providers
addressTypes: [AddressType.solana, AddressType.ethereum],
appId: "your-app-id", // Required when using embedded providers (google, apple, phantom, etc.)
// Optional:
// embeddedWalletType: "user-wallet", // or "app-wallet"
// apiBaseUrl: "https://api.phantom.app/v1/wallets",
}}
theme={darkTheme} // or lightTheme, or custom theme
appIcon="https://your-app.com/icon.png"
appName="Your App Name"
>
<App />
</PhantomProvider>;
// Simple connection with ConnectButton component
function WalletComponent() {
const { isConnected, addresses } = usePhantom();
const { solana } = useSolana();
const { ethereum } = useEthereum();
// ConnectButton handles the entire connection flow with built-in modal
return (
<div>
<ConnectButton fullWidth />
{isConnected && (
<div>
<p>Connected addresses:</p>
{addresses.map(addr => (
<p key={addr.address}>
{addr.addressType}: {addr.address}
</p>
))}
</div>
)}
</div>
);
}
// Advanced usage with chain-specific operations
function AdvancedComponent() {
const { solana } = useSolana();
const { ethereum } = useEthereum();
const signMessages = async () => {
const solanaSignature = await solana.signMessage("Hello Solana!");
const accounts = await ethereum.getAccounts();
const ethSignature = await ethereum.signPersonalMessage("Hello Ethereum!", accounts[0]);
};
return <button onClick={signMessages}>Sign Messages</button>;
}@phantom/browser-sdk - Core browser SDK with dual provider support and chain-specific APIs.
import { BrowserSDK, AddressType } from "@phantom/browser-sdk";
// Injected Provider Only (Browser Extension)
const sdk = new BrowserSDK({
providers: ["injected"], // Only allow browser extension
addressTypes: [AddressType.solana, AddressType.ethereum],
});
// Multiple Providers (Browser Extension + Embedded Auth)
// const sdk = new BrowserSDK({
// providers: ["google", "apple", "phantom", "injected"], // Allow all auth methods
// addressTypes: [AddressType.solana, AddressType.ethereum],
// appId: "your-app-id", // Required when using embedded providers
// // Optional:
// // embeddedWalletType: "user-wallet",
// // apiBaseUrl: "https://api.phantom.app/v1/wallets",
// });
// Connect through SDK (provider parameter is required)
const { addresses } = await sdk.connect({ provider: "injected" });
// Chain-specific operations
const solanaSignature = await sdk.solana.signMessage("Hello Solana!");
const ethResult = await sdk.ethereum.sendTransaction({
to: "0x742d35Cc6634C0532925a3b8D4C8db86fB5C4A7E",
value: "1000000000000000000",
gas: "21000",
});@phantom/server-sdk - Server-side SDK for backend applications with built-in authentication.
import { ServerSDK, NetworkId } from "@phantom/server-sdk";
const sdk = new ServerSDK({
organizationId: process.env.ORGANIZATION_ID,
appId: process.env.APP_ID,
apiPrivateKey: process.env.PRIVATE_KEY,
apiBaseUrl: process.env.API_URL,
});
// Create wallet
const wallet = await sdk.createWallet("User Wallet");
// Sign messages
const signature = await sdk.signMessage({
walletId: wallet.walletId,
message: "Hello from Phantom!",
networkId: NetworkId.SOLANA_MAINNET,
});
// Sign transactions - supports multiple formats
// Solana Web3.js Transaction
const solanaTransaction = new Transaction().add(/* instructions */);
await sdk.signAndSendTransaction({
walletId: wallet.walletId,
transaction: solanaTransaction, // Native Solana transaction object
networkId: NetworkId.SOLANA_MAINNET,
});
// Ethereum/EVM transaction object
const evmTransaction = {
to: "0x742d35Cc6634C0532925a3b8D4C8db86fB5C4A7E",
value: 1000000000000000000n,
data: "0x",
};
await sdk.signAndSendTransaction({
walletId: wallet.walletId,
transaction: evmTransaction, // Viem/Ethers transaction object
networkId: NetworkId.ETHEREUM_MAINNET,
});
// Raw bytes or hex strings
await sdk.signAndSendTransaction({
walletId: wallet.walletId,
transaction: "0x01020304", // Hex string
networkId: NetworkId.ETHEREUM_MAINNET,
});You can find example applications in the examples/ folder:
examples/with-modal- React SDK with ConnectButton and modal UIexamples/react-sdk-demo-appexamples/browser-sdk-demo-appexamples/react-native-sdk-demo-appexamples/with-nextjsexamples/with-wagmi
Below is an explanation of how the different packages of this repository work together.
These are the main SDKs that developers use to integrate Phantom Wallet:
@phantom/server-sdk - Backend SDK
Server-side SDK for backend applications with built-in authentication. Depends on:
@phantom/clientfor API communication@phantom/api-key-stamperfor request authentication
@phantom/react-sdk - React Hooks & Components
Thin wrapper over @phantom/browser-sdk that provides React hooks, context providers, and pre-built UI components for Phantom integration.
Features:
- React hooks:
usePhantom,useConnect,useDisconnect,useSolana,useEthereum ConnectButtoncomponent - Ready-to-use button that handles the complete connection flow- Built-in connection modal with authentication providers (Google, Apple, Phantom Login, Browser Extension)
- Theme system with
darkThemeandlightThemepresets - Automatic mobile deeplink support for Phantom mobile app
@phantom/browser-sdk - Vanilla JS/TS SDK
Core browser SDK supporting both injected (extension) and embedded (non-custodial) providers. Depends on:
@phantom/embedded-provider-corefor embedded wallet functionality@phantom/browser-injected-sdkfor extension integration@phantom/clientfor API communication@phantom/indexed-db-stamperfor secure browser-based authentication
@phantom/react-native-sdk - Mobile SDK
SDK for React Native and Expo applications. Depends on:
@phantom/embedded-provider-corefor embedded wallet functionality@phantom/clientfor API communication- Platform-specific secure storage for authentication
These are the foundational packages that power the entry point SDKs:
@phantom/embedded-provider-core - Embedded Wallet Orchestration
Platform-agnostic core that orchestrates authentication flows for embedded wallets and provides signing interfaces. This is the heart of the embedded wallet functionality, handling:
- Wallet creation and authentication
- Multi-chain signing interfaces (Solana, Ethereum, etc.)
- Session management
- Event handling
@phantom/browser-injected-sdk - Extension Integration
Interfaces with the Phantom browser extension, detecting its presence and providing a unified API to communicate with the injected provider.
@phantom/client - HTTP API Client
HTTP wrapper for interfacing with the Phantom API. All requests must be cryptographically signed (stamped) using one of the stamper packages.
@phantom/api-key-stamper - Server Authentication
Stamps API requests with cryptographic signatures using private API keys. Used by @phantom/server-sdk for backend authentication.
@phantom/indexed-db-stamper - Browser Authentication
Stamps API requests using non-extractable cryptographic keys stored in IndexedDB. Used by @phantom/browser-sdk for secure browser-based authentication.
@phantom/chain-interfaces - Multi-Chain Type Definitions
TypeScript interfaces and types for different blockchain networks (Solana, Ethereum, etc.).
@phantom/sdk-types - Shared Type Definitions
Common TypeScript types used across all SDK packages.
@phantom/constants - Shared Constants
Environment URLs, configuration values, and other constants used across packages.
@phantom/parsers - Data Parsers
Utilities for parsing and transforming blockchain data formats.
@phantom/crypto - Cryptographic Utilities
Platform-agnostic cryptographic operations (signing, hashing, key generation).
@phantom/base64url - URL-Safe Base64
Encoding/decoding utilities for URL-safe base64 operations.
@phantom/utils - General Utilities
Miscellaneous utility functions used across packages.
Frontend Entry Points:
react-sdk → browser-sdk → embedded-provider-core → client → (api-key-stamper | indexed-db-stamper)
→ browser-injected-sdk
Backend Entry Point:
server-sdk → client → api-key-stamper
Mobile Entry Point:
react-native-sdk → embedded-provider-core → client → api-key-stamper
Phantom SDKs support multiple blockchain networks across Solana and EVM chains.
Solana: Mainnet, Devnet, Testnet
EVM Chains:
- Ethereum (Mainnet, Sepolia)
- Polygon (Mainnet, Amoy)
- Base (Mainnet, Sepolia)
- Arbitrum (One, Sepolia)
- Monad (Mainnet, Testnet)
Coming Soon: Bitcoin, Sui
Different SDKs use different network identifiers:
- @phantom/server-sdk - Uses
NetworkIdenum for backend operations - @phantom/browser-sdk and @phantom/react-sdk - Use chain IDs (numbers) for network switching
Phantom SDKs are in active development and will be prioritizing features requested by early adopters. If you are interested in working with us, please email us at [email protected] or message @brianfriel on Telegram.
The embedded wallet is a beta version, and Phantom will not be liable for any losses or damages suffered by you or your end users.
Any suggestions, enhancement requests, recommendations, or other feedback provided by you regarding the embedded wallet will be the exclusive property of Phantom. By using this beta version and providing feedback, you agree to assign any rights in that feedback to Phantom.
This project uses the command yarn changeset to generate new versions for the different packages.
In your pull request, run the command yarn changeset, select which packages are affected and commit the generated files.
After this pull request is merged a new one will be generated automatically with the release. The CI system will release the new versions upon merge.