Skip to content
Starknet Start

useAccount

Access the currently connected account, if any.

Usage

import {  } from "@starknetfoundation/starknet-start-react";
 
const { ,  } = ();

Listening for changes

You can listen for the connection/disconnection events using the useEffect hook.

import {  } from "react";
import {  } from "@starknetfoundation/starknet-start-react";
 
const { ,  } = ();
 
(() => {
  if ( === "disconnected") {
    // on disconnect
  } else if ( === "connected") {
    // on connect
  }
}, [, ]);

Returns

address

  • Type: 0x${string} | undefined

The address of the currently connected account.

connector

  • Type: WalletWithStarknetFeatures | undefined

The wallet used to connect the account.

chainId

  • Type: bigint | undefined

The account's chain id.

status

  • Type: "connected" | "disconnected" | "connecting" | "reconnecting"

Account connection status.

isConnecting

  • Type: boolean | undefined

Derived from status.

isReconnecting

  • Type: boolean | undefined

Derived from status.

isConnected

  • Type: boolean | undefined

Derived from status.

isDisconnected

  • Type: boolean | undefined

Derived from status.