Skip to main content
The Phantom Connect Browser SDK provides a framework-agnostic JavaScript/TypeScript interface for connecting to existing Phantom user wallets in web apps.

Features

  • Framework-agnostic: Works with vanilla JavaScript/TypeScript and all web frameworks.
  • Multi-chain support: Solana (available now), other chains coming soon.
  • Native transaction support: Sign and send native transaction objects on supported chains.
  • Flexible authentication providers: OAuth (Google, Apple), Phantom extension, embedded wallets, and injected providers.
  • User wallet integration: Connects to existing Phantom user wallets across supported chains.
  • TypeScript support: Fully typed API surface.

Security

The Phantom Connect Browser SDK connects to existing Phantom user wallets, ensuring:
  • Users control their own wallets and private keys.
  • Users maintain full control of their assets.
  • Integration with Phantom’s secure wallet infrastructure.
  • No private key handling in your app.

Prerequisites

  • Register your app: Sign up or log in to the Phantom Portal and register your app.
  • Obtain your App ID:
    • In Phantom Portal, go to your app and open URL Config (left-hand menu). This page shows your allowed origins and redirect URLs.
    • Scroll down to the App ID section at the bottom of the page — your App ID is listed there, below the URL configurations.
    • Copy the App ID for use in your integration.
  • 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 the embedded provider, you’ll need to configure authentication options:
authOptions: {
  redirectUrl: "https://yourapp.com/auth/callback", // Your callback page
}
Notes about redirectUrl:
  • Must be an existing page/route in your app.
  • Must be allowlisted in your Phantom Portal app configuration.
  • This is where users will be redirected after completing OAuth authentication.

Installation

npm install @phantom/browser-sdk@beta

Quick start

User wallet connection

import { BrowserSDK, AddressType } from "@phantom/browser-sdk";

// Connect to Phantom embeded wallet
const sdk = new BrowserSDK({
  providerType: "embedded", // or "injected" for browser extension
  addressTypes: [AddressType.solana, AddressType.ethereum],
  appId: "your-app-id",
  authOptions: {
    authUrl: "https://connect.phantom.app/login",
    redirectUrl: "https://yourapp.com/auth/callback", // Must be an existing page in your app and whitelisted in Phantom Portal
  },
});

const { addresses } = await sdk.connect();
console.log("Connected addresses:", addresses);

// Chain-specific operations
const message = "Hello from Phantom!";
const solanaSignature = await sdk.solana.signMessage(message);

// Encode the message as hex for EVM
const encoded = "0x" + Buffer.from(message, "utf8").toString("hex");
const ethSignature = await sdk.ethereum.signPersonalMessage(encoded, addresses[1].address);

Chain-specific APIs

The SDK provides separate interfaces for each blockchain with optimized methods:

Solana chain (sdk.solana)

// Message signing
const signature = await sdk.solana.signMessage("Hello Solana!");

// Transaction signing (without sending)
const signedTx = await sdk.solana.signTransaction(transaction);

// Sign and send transaction
const result = await sdk.solana.signAndSendTransaction(transaction);

// Network switching
await sdk.solana.switchNetwork('devnet');

Ethereum chain (sdk.ethereum)

// Message signing
const signature = await sdk.ethereum.signPersonalMessage(message, address);

// Transaction sending
const result = await sdk.ethereum.sendTransaction({
  to: "0x...",
  value: "1000000000000000000", // 1 ETH in wei
  gas: "21000",
});

// Network switching
await sdk.ethereum.switchChain(1); // Ethereum mainnet
Supported EVM Networks:
NetworkChain IDUsage
Ethereum Mainnet1ethereum.switchChain(1)
Ethereum Sepolia11155111ethereum.switchChain(11155111)
Polygon Mainnet137ethereum.switchChain(137)
Polygon Amoy80002ethereum.switchChain(80002)
Base Mainnet8453ethereum.switchChain(8453)
Base Sepolia84532ethereum.switchChain(84532)
Arbitrum One42161ethereum.switchChain(42161)
Arbitrum Sepolia421614ethereum.switchChain(421614)
Monad Mainnet143ethereum.switchChain(143)
Monad Testnet10143ethereum.switchChain(10143)

Auto-Confirm

The SDK provides Auto-Confirm functionality that allows automatic transaction confirmation for specified chains.
import { NetworkId } from "@phantom/browser-sdk";

// Enable auto-confirm for specific chains
const result = await sdk.enableAutoConfirm({
  chains: [NetworkId.SOLANA_MAINNET, NetworkId.ETHEREUM_MAINNET]
});

// Enable auto-confirm for all supported chains  
const result = await sdk.enableAutoConfirm();

// Disable auto-confirm
await sdk.disableAutoConfirm();

// Get current status
const status = await sdk.getAutoConfirmStatus();

Available AddressType values

AddressTypeSupported chains
AddressType.solanaSolana Mainnet, Devnet, Testnet
AddressType.ethereumEthereum, Polygon, Arbitrum, and more

What you can do

Starter kits and examples

Framework-agnostic JavaScript examples and templates:

Additional resources