The React Hooks package provides hooks for accessing user state, connecting to and disconnecting from wallets.
Installation
pnpm add @aurum-sdk/core @aurum-sdk/hooks
Provider Setup
Wrap your application root in AurumProvider with an initialized Aurum instance:
import { Aurum } from '@aurum-sdk/core' ;
import { AurumProvider } from '@aurum-sdk/hooks' ;
const aurum = new Aurum ({
brand: { appName: 'Your App Name' },
wallets: {
embedded: { projectId: 'cdp-project-id' },
walletConnect: { projectId: 'reown-project-id' },
},
});
function App () {
return (
< AurumProvider aurum = { aurum } >
< YourApp />
</ AurumProvider >
);
}
See Core SDK Configuration for all available Aurum options.
Available Hooks
useAurum()
Access the raw Aurum SDK instance for advanced use cases.
const { aurum , isReady } = useAurum ();
The Aurum SDK instance passed to AurumProvider.
true once the SDK has finished initializing and restored any persisted connection.
useAccount()
Access connected user information. Updates automatically when the connection state changes.
const {
publicAddress ,
walletName ,
walletId ,
email ,
isConnected ,
isInitializing ,
} = useAccount ();
The connected wallet address
Display name of the connected wallet
Identifier of the connected wallet
User’s email (only present for email wallets)
true if a wallet is currently connected
true while the SDK is checking for / restoring a persisted connection
useConnect()
Connect to a wallet via the modal or directly by wallet ID.
const { connect , isPending , error } = useConnect ();
// Open wallet selection modal
await connect ();
// Or connect directly to a specific wallet (skips modal)
import { WalletId } from '@aurum-sdk/types' ;
await connect ( WalletId . MetaMask );
connect
(walletId?: WalletId) => Promise<string>
Opens the modal or connects directly if walletId is provided. Returns the connected address.
true while a connection attempt is in progress.
The error if the last connection attempt failed.
WalletId.Email cannot be used with connect(walletId) — use the dedicated Headless API methods instead.
Do not use useConnect() with <ConnectWidget>. Instead use useAccount() to react to connection state changes when using the widget.
useDisconnect()
Disconnect the current wallet.
const { disconnect } = useDisconnect ();
await disconnect ();
useChain()
Access current chain information and switch networks.
import { sepolia } from 'viem/chains' ;
const { chainId , switchChain , isPending , error } = useChain ();
await switchChain ( sepolia . id , sepolia );
The current chain ID as a hex string.
switchChain
(chainId: number | string, chain?: Chain) => Promise<void>
Switches to the specified chain. Pass the chain definition to prompt the user to add it if it’s not yet configured.
The error if the user rejected the request.
Core SDK Framework-agnostic API
Headless Mode Build custom connection UIs