Skip to main content
Let users sign in with familiar social accounts. Phantom Connect creates a non-custodial wallet for them automatically.
import { PhantomProvider, useModal, usePhantom, useAccounts, darkTheme } from "@phantom/react-sdk";
import { AddressType } from "@phantom/browser-sdk";

function App() {
  return (
    <PhantomProvider
      config={{
        providers: ["google", "apple"],
        appId: "your-app-id",
        addressTypes: [AddressType.solana],
        authOptions: {
          redirectUrl: "https://yourapp.com/auth/callback",
        },
      }}
      theme={darkTheme}
      appName="Your App"
    >
      <LoginPage />
    </PhantomProvider>
  );
}

function LoginPage() {
  const { open } = useModal();
  const { isConnected } = usePhantom();
  const addresses = useAccounts();

  if (isConnected && addresses) {
    return (
      <div>
        <p>Welcome! Your wallet: {addresses[0]?.address}</p>
      </div>
    );
  }

  return (
    <div>
      <h1>Sign in to get started</h1>
      <button onClick={open}>Continue with Google or Apple</button>
    </div>
  );
}

Handle the OAuth callback

Create a callback page at your redirectUrl:
// app/auth/callback/page.tsx (Next.js)
"use client";
import { ConnectBox } from "@phantom/react-sdk";

export default function AuthCallback() {
  return (
    <div style={{ display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100vh" }}>
      <ConnectBox />
    </div>
  );
}