Warning

B3 Global Accounts are deprecated. Upside and AnySpend now sign in with your own wallet. If you held funds in a Global Account and need help, ask in the B3 Discord. The team never DMs first and will never ask for your seed phrase or private key.

Authentication Strategies

B3 Global Accounts support multiple authentication strategies to fit your application's needs.

Social Login

Google Authentication

tsx
import { SignInWithB3 } from "@b3dotfun/sdk/global-account/react";const b3Chain = { id: 8453, name: "Base", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpc: "YOUR_BASE_RPC_URL",};function GoogleAuth() { return ( <SignInWithB3 strategies={["google"]} chain={b3Chain} partnerId="your-partner-id" onLoginSuccess={(globalAccount) => { console.log("Google auth successful:", globalAccount); }} onError={async (error) => { console.error("Authentication failed:", error); }} /> );}

Discord Authentication

tsx
import { SignInWithB3 } from "@b3dotfun/sdk/global-account/react";const b3Chain = { id: 8453, name: "Base", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpc: "YOUR_BASE_RPC_URL",};function DiscordAuth() { return ( <SignInWithB3 strategies={["discord"]} chain={b3Chain} partnerId="your-partner-id" onLoginSuccess={(globalAccount) => { console.log("Discord auth successful:", globalAccount); }} onError={async (error) => { console.error("Authentication failed:", error); }} /> );}

Multiple Specific Strategies

You can allow users to choose from multiple specific authentication providers:

tsx
import { SignInWithB3 } from "@b3dotfun/sdk/global-account/react";const b3Chain = { id: 8453, name: "Base", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpc: "YOUR_BASE_RPC_URL",};function MultipleAuthOptions() { return ( <SignInWithB3 strategies={["google", "discord", "x"]} chain={b3Chain} partnerId="your-partner-id" onLoginSuccess={(globalAccount) => { console.log("Auth successful:", globalAccount); }} /> );}
Note

Specify an array of strategies to show only those authentication options to your users.

Headless Authentication

For custom implementations, use the headless authentication service:

Basic Authentication

typescript
import { authenticate } from "@b3dotfun/sdk/global-account/app";async function authenticateUser(accessToken: string, identityToken: string) { try { const authResult = await authenticate(accessToken, identityToken, { // additional configuration }); if (authResult) { console.log("Authentication successful:", authResult); return authResult; } else { console.log("Authentication failed"); return null; } } catch (error) { console.error("Authentication error:", error); throw error; }}

React Native Authentication

typescript
// For React Native applicationsimport { authenticate } from "@b3dotfun/sdk/global-account/app";async function authenticateInReactNative() { const result = await authenticate("access-token", "identity-token"); return result;}

Authentication Hooks

Note

useB3 is deprecated. It is an alias for useB3Config and returns the B3Provider configuration, not the signed-in account. Read the account from useAccountWallet, below. Use useAuthStore for the isAuthenticated and isAuthenticating states.

useAccountWallet Hook

Access wallet information and connection status:

tsx
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";function WalletInfo() { const { address, ensName } = useAccountWallet(); return ( <div> {address && ( <div> <p>Wallet Address: {address}</p> {ensName && <p>Name: {ensName}</p>} </div> )} </div> );}

Error Handling

Implement proper error handling for authentication flows:

tsx
import { useState } from "react";function AuthWithErrorHandling() { const [authError, setAuthError] = useState<string | null>(null); return ( <div> <SignInWithB3 strategies={["google", "discord"]} chain={b3Chain} partnerId="your-partner-id" onLoginSuccess={(globalAccount) => { setAuthError(null); console.log("Success:", globalAccount); }} onError={async (error) => { setAuthError(error.message); console.error("Auth error:", error); }} /> {authError && ( <div className="error"> Authentication failed: {authError} </div> )} </div> );}

Best Practices

Partner ID

Always use your unique partner ID for proper attribution and analytics.

Error Handling

Implement comprehensive error handling for better user experience.

Session Management

Set appropriate session durations based on your application's security needs.

Environment Config

Use proper environment variables for different deployment stages.

Component API Reference

SignInWithB3

The main authentication button component.

Props

strategiesAllowedStrategy[]path

Array of authentication strategies to display. Options include: "google", "github", "email", "discord", "x", "apple", "walletConnect", "io.metamask", "com.coinbase.wallet".

Leave undefined to show all options.

chainChainrequiredpath

Blockchain chain configuration object with id, name, nativeCurrency, and rpc.

partnerIdstringrequiredpath

Your unique partner ID for B3 Global Accounts.

onLoginSuccess(account: Account) => voidpath

Callback function called when authentication succeeds.

onError(error: Error) => Promise<void>path

Async callback function called when an error occurs.

closeAfterLoginbooleanpathdefault: false

Whether to close the modal after successful login.

buttonTextstring | ReactNodepath

Custom text or component for the sign-in button.

booleanpathdefault: true

Whether to show the B3 logo in the button.

Available Authentication Strategies

B3 Global Accounts supports the following authentication methods:

Strategy Type Description

"google" Social Google OAuth authentication

"discord" Social Discord OAuth authentication

"github" Social GitHub OAuth authentication

"x" Social X (formerly Twitter) authentication

"apple" Social Apple Sign In

"guest" Passwordless Guest authentication without signup

"email" Passwordless Email verification code authentication

"walletConnect" Wallet WalletConnect protocol

"io.metamask" Wallet MetaMask browser extension

"com.coinbase.wallet" Wallet Coinbase Wallet

Next Steps

Hooks Reference

Explore all available React hooks.

Learn More
Examples

See complete integration examples.

Learn More
Ask a question... ⌘I