Skip to content

useWalletAuth

Authenticate users with external wallets using Sign-In with Ethereum (SIWE).

Usage

import { embeddedWalletId, useWalletAuth } from '@openfort/react';
 
function WalletLogin() {
  const { connectWallet, availableWallets, isLoading } = useWalletAuth();
 
  const connect = (id: string) => connectWallet({ connector: id });
  const connectEmbedded = () => connectWallet({ connector: embeddedWalletId });
 
  return null;
}

Return type

type WalletAuthReturn = {
  availableWallets: AvailableWallet[]
  walletConnectingTo: string | null
  connectWallet(options: ConnectWalletOptions): Promise<void | { error: OpenfortError }>
  linkWallet(options: ConnectWalletOptions): Promise<void | { error: OpenfortError }>
  isLoading: boolean
  isError: boolean
  isSuccess: boolean
  error?: OpenfortError | null
}
 
type ConnectWalletOptions = {
  connector: string | Connector
}
 
type AvailableWallet = {
  id: string
  connector: Connector
  name: string
  icon: React.ReactNode
  iconShape: 'circle' | 'square' | 'squircle'
  isInstalled?: boolean
}