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
- React UI - Complete UI solution with pre-built modals
- Browser SDK - Vanilla JavaScript/TypeScript
- React Native SDK - Mobile app integration
All packages with links to documentation:
- @phantom/react-sdk - React hooks and components (NPM)
- @phantom/browser-sdk - Core browser SDK (NPM)
- @phantom/server-sdk - Server-side SDK (NPM)
- @phantom/react-ui - React UI components
- @phantom/client - HTTP client library
- @phantom/api-key-stamper - API authentication
- @phantom/browser-injected-sdk - Browser extension integration
- @phantom/wallet-sdk -
⚠️ DEPRECATED - Use @phantom/browser-sdk or @phantom/react-sdk instead (NPM)
All frontend SDKs support two provider types:
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
Create or use non-custodial embedded wallets within your application:
- App Wallet: Fresh wallet created per application (unfunded, app-specific)
- User Wallet: User's Phantom wallet accessed via authentication (potentially funded, portable across apps)
This repository contains multiple SDKs for different integration needs, prioritized by ease of use:
@phantom/react-sdk - React hooks for Phantom integration with chain-specific APIs.
import { PhantomProvider, useConnect, useSolana, useEthereum, AddressType } from "@phantom/react-sdk";
// App wrapper with provider selection
<PhantomProvider
config={{
providerType: "injected", // or "embedded"
addressTypes: [AddressType.solana, AddressType.ethereum],
// For embedded wallets:
// embeddedWalletType: "app-wallet",
// apiBaseUrl: "https://api.phantom.app/v1/wallets",
// appId: "your-app-id",
}}
>
<App />
</PhantomProvider>;
// Component with chain-specific operations
function WalletComponent() {
const { connect } = useConnect();
const solana = useSolana();
const ethereum = useEthereum();
const handleConnect = async () => {
const { addresses } = await connect();
console.log("Connected addresses:", addresses);
};
const signMessages = async () => {
const solanaSignature = await solana.signMessage("Hello Solana!");
const accounts = await ethereum.getAccounts();
const ethSignature = await ethereum.signPersonalMessage("Hello Ethereum!", accounts[0]);
};
}
@phantom/browser-sdk - Core browser SDK with dual provider support and chain-specific APIs.
import { BrowserSDK, AddressType } from "@phantom/browser-sdk";
// Injected Provider (Browser Extension)
const sdk = new BrowserSDK({
providerType: "injected",
addressTypes: [AddressType.solana, AddressType.ethereum],
});
// Embedded Provider (Non-Custodial)
// const sdk = new BrowserSDK({
// providerType: "embedded",
// embeddedWalletType: "app-wallet",
// addressTypes: [AddressType.solana, AddressType.ethereum],
// apiBaseUrl: "https://api.phantom.app/v1/wallets",
// appId: "your-app-id",
// });
// Connect through SDK
const { addresses } = await sdk.connect();
// 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,
});
@phantom/react-ui - Pre-built React UI components with automatic modal injection and chain-specific operations.
import { PhantomProvider, useConnect, useSolana, useEthereum, AddressType } from "@phantom/react-ui";
// App wrapper - includes react-sdk + UI theme
<PhantomProvider
config={{
providerType: "embedded", // or "injected"
addressTypes: [AddressType.solana, AddressType.ethereum],
apiBaseUrl: "https://api.phantom.app/v1/wallets",
appId: "your-app-id",
}}
theme="dark"
>
<App />
</PhantomProvider>;
// Component - UI appears automatically
function WalletOperations() {
const { connect } = useConnect();
const solana = useSolana();
const ethereum = useEthereum();
const handleOperations = async () => {
// Connection modals appear automatically
await connect();
// Chain-specific operations with UI
await solana.signAndSendTransaction(solanaTransaction);
await ethereum.sendTransaction(ethTransaction);
};
}
@phantom/client - Low-level HTTP client for Phantom's API with authentication support.
@phantom/api-key-stamper - Ed25519 authentication for API requests.
@phantom/browser-injected-sdk - Direct integration with Phantom browser extension.
You can find example applications in the examples/
folder:
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.