Hooks

React hooks that provide deeper access into the wallet APIs

Inside the <ArweaveWalletKit>, you can use all kinds of hooks that are reactive to the different strategies. Some of the hooks and/or api functions might not be supported by all wallets.

useConnection

The core hook for connecting / disconnecting a strategy.

Usage

const { connected, connect, disconnect } = useConnection();

// initiate connection
await connect();

// disconnect the connected strategy
await disconnect();

// is there a strategy connected?
connected ? "wallet connected" : "no connected wallet";

useApi

API hook. Returns the active strategy's API as an intractable object. Can be used to sign/encrypt, etc.

Usage

const api = useApi();

// sign
await api.sign(transaction);

// encrypt
await api.encrypt(...)

Some API functions might not be supported depending on the strategy the user chose. (e.g.: Othent does not support the signature() function.

useProfileModal

Toggle / display a modal with profile information and a disconnect button.

const profileModal = useProfileModal();

profileModal.setOpen(true);

useActiveAddress

Active address hook. Requires the ACCESS_ADDRESS and the ACCESS_ALL_ADDRESSES permission.

Usage

const address = useActiveAddress();

usePublicKey

Active address hook. Requires the ACCESS_PUBLIC_KEY permission.

Usage

const publicKey = usePublicKey();

usePermissions

Permissions hook. Returns the permissions given to the app, known by Arweave Wallet Kit.

Usage

const permissions = usePermissions();

useAddresses

All addresses hook. Returns the addresses in the connected wallet, known by Arweave Wallet Kit. Requires the ACCESS_ALL_ADDRESSES permission.

Usage

const addresses = useAddresses();

useWalletNames

All addresses hook. Returns the addresses in the connected wallet, known by Arweave Wallet Kit. Requires the ACCESS_ALL_ADDRESSES permission.

Usage

const walletNames = useWalletNames();

useStrategy

Active strategy hook. Returns the currently used strategy's ID ("arconnect", "webwallet", etc.)

Usage

const strategy = useStrategy();

Last updated