一键导入
setup-react-app
Scaffold a React app with Phantom Connect SDK for wallet integration, including social login and Solana support
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a React app with Phantom Connect SDK for wallet integration, including social login and Solana support
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
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.
Configure Google and Apple social login with Phantom Connect SDK to enable embedded wallet creation
Build and send SOL transfers with Phantom Connect SDK, including transaction construction, signing, and verification
Scaffold a vanilla JS/TS app with Phantom Browser SDK for wallet integration, without any framework dependency
Scaffold a React Native (Expo) app with Phantom React Native SDK for mobile wallet integration, including polyfills and deep linking
Implement message signing with Phantom Connect SDK for Solana and EVM, including Sign-in with Solana (SIWS) authentication
| name | setup-react-app |
| description | Scaffold a React app with Phantom Connect SDK for wallet integration, including social login and Solana support |
npm install @phantom/react-sdk @solana/web3.js
Wrap your app's root component in PhantomProvider with the required configuration:
import { PhantomProvider } from "@phantom/react-sdk";
function App() {
return (
<PhantomProvider
config={{
appId: "your-app-id-from-phantom-portal",
providers: ["google", "apple"],
addressTypes: ["solana", "ethereum"],
}}
>
<YourApp />
</PhantomProvider>
);
}
Required config fields:
appId — Register at Phantom Portal to obtain this.providers — Social login providers to enable (e.g. ["google", "apple"]).addressTypes — Blockchain address types to request (e.g. ["solana"], ["solana", "ethereum"]).Use the built-in ConnectButton component for the simplest integration:
import { ConnectButton } from "@phantom/react-sdk";
function Navbar() {
return (
<nav>
<ConnectButton />
</nav>
);
}
Wire up the core hooks to access wallet state and chain-specific APIs:
import {
useConnect,
useAccounts,
useDisconnect,
useSolana,
} from "@phantom/react-sdk";
function WalletInfo() {
const { isConnected } = useConnect();
const { accounts } = useAccounts();
const { disconnect } = useDisconnect();
const solana = useSolana();
if (!isConnected) {
return <p>Not connected</p>;
}
const solanaAccount = accounts.find((a) => a.chain === "solana");
return (
<div>
<p>Address: {solanaAccount?.address}</p>
<button onClick={disconnect}>Disconnect</button>
</div>
);
}
Always wrap connection logic in try-catch:
import { useConnect } from "@phantom/react-sdk";
function ConnectFlow() {
const { connect } = useConnect();
const handleConnect = async () => {
try {
await connect();
} catch (error) {
console.error("Connection failed:", error);
}
};
return <button onClick={handleConnect}>Connect Wallet</button>;
}
| Hook | Purpose |
|---|---|
useConnect | Connect/disconnect, check isConnected |
useAccounts | Access connected wallet accounts |
useDisconnect | Disconnect the current session |
useSolana | Access Solana-specific APIs (sign, send) |
useEthereum | Access EVM-specific APIs |
signAndSendTransaction — signTransaction is NOT supported for embedded wallets.appId.