phantom-connect
Original:🇺🇸 English
Translated
Build wallet-connected applications with the Phantom Connect SDK for Solana. Use when integrating Phantom wallets into React, React Native, or vanilla JS/TS apps — including wallet connection, social login (Google/Apple), transaction signing, message signing, token-gated access, crypto payments, and NFT minting. Covers @phantom/react-sdk, @phantom/react-native-sdk, and @phantom/browser-sdk.
2installs
Sourcesendaifun/skills
Added on
NPX Install
npx skill4agent add sendaifun/skills phantom-connectTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Phantom Connect SDK
Build wallet-connected Solana applications with the Phantom Connect SDK ecosystem.
SDK Selection
| Platform | SDK | Package |
|---|---|---|
| React web apps | React SDK | |
| React Native / Expo | React Native SDK | |
| Vanilla JS / Vue / Angular | Browser SDK | |
Prerequisites
- Phantom Portal Account — Register at phantom.com/portal
- App ID — Get from Portal → App → Set Up
- Allowlisted URLs — Add domains and redirect URLs in Portal
Auth Providers
| Provider | Description | Requires appId |
|---|---|---|
| Phantom browser extension | No |
| Google OAuth (embedded wallet) | Yes |
| Apple ID (embedded wallet) | Yes |
Critical Rules
- Always use —
signAndSendTransactionandsignTransactionare NOT supported for embedded walletssignAllTransactions - Always use from
LAMPORTS_PER_SOLfor amount conversion — never hardcode@solana/web3.js1000000000 - Wrap all async SDK calls in try-catch — users can reject prompts at any time
- Check before signing — verify wallet connection before any operation
isConnected - React Native: must be the FIRST import — before any other imports
react-native-get-random-values - BrowserSDK must be a singleton — create one instance per app, never multiple
- Import from
AddressTypeonly@phantom/browser-sdk - Use devnet for testing, mainnet-beta for production — never test against mainnet with real funds
- Never expose private keys — Phantom handles all signing internally
- Embedded wallet spending limit: $1,000 USD per day per app per user
- Social login sessions persist 7 days from last auth event — handle expiration gracefully
Quick Start
React SDK
tsx
import { PhantomProvider, useModal, usePhantom, darkTheme } from "@phantom/react-sdk";
import { AddressType } from "@phantom/browser-sdk";
function App() {
return (
<PhantomProvider
config={{
providers: ["google", "apple", "injected"],
appId: "your-app-id",
addressTypes: [AddressType.solana],
authOptions: { redirectUrl: "https://yourapp.com/callback" },
}}
theme={darkTheme}
>
<YourApp />
</PhantomProvider>
);
}React Native SDK
tsx
// CRITICAL: Must be first import
import "react-native-get-random-values";
import { PhantomProvider, AddressType, darkTheme } from "@phantom/react-native-sdk";
// Requires app.json: { "expo": { "scheme": "myapp", "plugins": [...] } }Browser SDK
ts
import { BrowserSDK, AddressType } from "@phantom/browser-sdk";
const sdk = new BrowserSDK({
providers: ["google", "apple", "injected"],
appId: "your-app-id",
addressTypes: [AddressType.solana],
autoConnect: true,
});Reference Docs
For detailed implementation patterns, read these files:
- references/react-sdk.md — Complete React SDK reference (hooks, components, theming)
- references/react-native-sdk.md — Mobile setup, Expo config, deep links
- references/browser-sdk.md — Vanilla JS patterns, events, wallet discovery
- references/transactions.md — Solana transaction patterns (SOL, SPL tokens)
- references/payments.md — Crypto payment flows (SOL, USDC, backend verification)
- references/token-gating.md — Token-gated access (client-side, server-side, NFT)
- references/nft-minting.md — NFT mint pages, Metaplex Core, compressed NFTs
Common Issues
| Issue | Solution |
|---|---|
| "appId required" | Add appId from Phantom Portal when using google/apple providers |
| Redirect not working | Allowlist redirectUrl in Phantom Portal |
| React Native crashes | Import |
| Extension not detected | Use |
| Use |
Resources
- Phantom Portal — App registration
- Phantom Docs — Full documentation
- SDK Examples — Working demos
- MCP Server — AI docs access