# Hooks

React hooks for authentication, wallet management, and UI control.

:::note
Try the hooks in our [Openfort playground](https://playground.openfort.io/).
:::

## Authentication

| Hook | Description |
|------|-------------|
| [`useUser`](/docs/products/embedded-wallet/react/hooks/useUser) | Current user, auth flags, and access token |
| [`useEmailAuth`](/docs/products/embedded-wallet/react/hooks/useEmailAuth) | Email/password authentication |
| [`useEmailOtpAuth`](/docs/products/embedded-wallet/react/hooks/useEmailOtpAuth) | Email OTP (passwordless) authentication |
| [`usePhoneOtpAuth`](/docs/products/embedded-wallet/react/hooks/usePhoneOtpAuth) | Phone OTP (SMS) authentication |
| [`useOAuth`](/docs/products/embedded-wallet/react/hooks/useOAuth) | OAuth provider authentication |
| [`useGuestAuth`](/docs/products/embedded-wallet/react/hooks/useGuestAuth) | Guest authentication |
| [`useConnectWithSiwe`](/docs/products/embedded-wallet/react/hooks/useConnectWithSiwe) | SIWE wallet authentication (from `@openfort/react/wagmi`) |
| [`useAuthCallback`](/docs/products/embedded-wallet/react/hooks/useAuthCallback) | OAuth and email verification callbacks |
| [`useSignOut`](/docs/products/embedded-wallet/react/hooks/useSignOut) | Sign out and clear session |
| [`useWalletAuth`](/docs/products/embedded-wallet/react/hooks/useWalletAuth) | Connect and link external wallets with SIWE (from `@openfort/react/wagmi`) |

## Wallets

| Hook | Chain | Description |
|------|-------|-------------|
| [`useEthereumEmbeddedWallet`](/docs/products/embedded-wallet/react/hooks/useEthereumEmbeddedWallet) | Ethereum | Address, chainId, provider, isConnected, plus create, setActive, export key. Accepts optional `options` with `chainId` and `recoveryParams`. |
| [`useSolanaEmbeddedWallet`](/docs/products/embedded-wallet/react/hooks/useSolanaEmbeddedWallet) | Solana | Embedded wallet: create, list, setActive, export key, cluster, rpcUrl. Accepts optional `options` with `cluster` (counterpart of Ethereum `chainId`) and `recoveryParams`. |

## Assets

| Hook | Description |
|------|-------------|
| [`useEthereumWalletAssets`](/docs/products/embedded-wallet/react/hooks/useEthereumWalletAssets) | Multi-token asset inventory for Ethereum (from `@openfort/react/ethereum`) |

## Permissions (Ethereum only)

| Hook | Description |
|------|-------------|
| [`useGrantPermissions`](/docs/products/embedded-wallet/react/hooks/useGrantPermissions) | Grant session key permissions (EIP-7715) |
| [`useRevokePermissions`](/docs/products/embedded-wallet/react/hooks/useRevokePermissions) | Revoke session key permissions |
| [`use7702Authorization`](/docs/products/embedded-wallet/react/hooks/use7702Authorization) | Sign EIP-7702 authorizations |

## UI

| Hook | Description |
|------|-------------|
| [`useUI`](/docs/products/embedded-wallet/react/hooks/useUI) | Modal control: open, close, openProfile |

## Core

| Hook | Description |
|------|-------------|
| [`useOpenfort`](/docs/products/embedded-wallet/react/hooks/useOpenfort) | Universal. Core SDK client: user, embeddedState, client, logout, updateUser, etc. |

## Utility

These hooks are exported from `@openfort/react/wagmi` (Ethereum/Wagmi only).

| 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.

```tsx
import { useChains } from '@openfort/react/wagmi'

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.

```tsx
import { useChainIsSupported } from '@openfort/react/wagmi'

function ChainStatus({ chainId }: { chainId?: number }) {
  const isSupported = useChainIsSupported(chainId)

  return <span>{isSupported ? 'Supported' : 'Unsupported'}</span>
}
```

## Types

| Type | Description |
|------|-------------|
| `CreateEmbeddedWalletOptions` | Options for `create()` on both `useEthereumEmbeddedWallet` and `useSolanaEmbeddedWallet`. See [Create wallet](/docs/products/embedded-wallet/react/wallet/create). |
| `CreateEmbeddedWalletResult` | Shape of `onSuccess` callback data: `{ account: EmbeddedAccount, error?: string }`. |
| `OpenfortHookOptions<T>` | Generic options for hooks: `onSuccess`, `onError`, `throwOnError`. Used by create, auth, and permissions hooks. See [Error handling](/docs/products/embedded-wallet/react/errors#openforthookoptions). |
| `SetRecoveryOptions` | Shared options for `setRecovery()` on both embedded wallet hooks: `previousRecovery`, `newRecovery`. |

## Constants

| Export | Description |
|--------|-------------|
| `embeddedWalletId` | Identifier for the Openfort embedded wallet ('xyz.openfort') |
| `OPENFORT_VERSION` | Current SDK version string |

:::note
Imports are tree-shaken by entry point: `@openfort/react`, `@openfort/react/ethereum`, `@openfort/react/solana`, `@openfort/react/wagmi`. Only import from the subpath you need.
:::
