Hooks
React hooks for authentication, wallet management, and UI control.
Authentication
| Hook | Description |
|---|---|
useUser | Current user and access token |
useEmailAuth | Email/password authentication |
useEmailOtpAuth | Email OTP (passwordless) authentication |
usePhoneOtpAuth | Phone OTP (SMS) authentication |
useOAuth | OAuth provider authentication |
useGuestAuth | Guest authentication |
useWalletAuth | SIWE wallet authentication |
useConnectWithSiwe | SIWE authentication after wallet connection |
useAuthCallback | OAuth and email verification callbacks |
useSignOut | Sign out and clear session |
Wallets
| Hook | Description |
|---|---|
useWallets | Wallet management and switching |
useWalletAssets | Wallet token balances |
Permissions
| Hook | Description |
|---|---|
useGrantPermissions | Grant session key permissions (EIP-7715) |
useRevokePermissions | Revoke session key permissions |
use7702Authorization | Sign EIP-7702 authorizations |
UI
| Hook | Description |
|---|---|
useUI | Modal control and navigation |
Utility
| Hook | Description |
|---|---|
useChains | Access configured blockchain chains |
useChainIsSupported | Check if a chain ID is supported |
useChains
Access all blockchain chains configured in the Wagmi config.
import { useChains } from '@openfort/react';
function ChainSelector() {
const chains = useChains();
return (
<select>
{chains.map(chain => (
<option key={chain.id} value={chain.id}>
{chain.name}
</option>
))}
</select>
);
}useChainIsSupported
Check if a specific chain ID is supported in the current configuration.
import { useChainIsSupported } from '@openfort/react';
function ChainStatus({ chainId }: { chainId?: number }) {
const isSupported = useChainIsSupported(chainId);
return <span>{isSupported ? 'Supported' : 'Unsupported'}</span>;
}