useAccount

Description

This hook provides an easy way to access the current status and information of a smart account in a React application, providing essential details such as the smart account address, client instance, and connection status.

Returns

  • address (Address | undefined)

  • smartAccountClient (ContextComethSmartAccountClient | null)

  • isConnected (boolean)

  • isDisconnected (boolean)

  • status (AccountStatus)

Example

import React from 'react';
import { useAccount } from "@cometh/connect-react-hooks";

const AccountInfo = () => {
  const { address, isConnected, status } = useAccount();

  return (
    <div>
      <h1>Account Information</h1>
      <p>Status: {status}</p>
      {isConnected ? (
        <p>Connected to account: {address}</p>
      ) : (
        <p>No account connected</p>
      )}
    </div>
  );
};

export default AccountInfo;

Last updated