Alchemy Logo

useConnectedUser

function useConnectedUser(): UseConnectedUserResult;

Defined in: account-kit/react/dist/types/hooks/useConnectedUser.d.ts:39

A React hook that returns the currently connected user across external wallets (EVM or Solana) or the smart account user from the client store. It prioritizes the EVM wallet connection, then Solana, and finally the smart account user.

Useful for building UI that needs a single "connected user" concept regardless of whether a smart account session exists.

  • If an EVM wallet is connected, returns { address, type: "eoa", orgId?, userId? }.
  • If a Solana wallet is connected, returns { solanaAddress, type: "eoa", orgId?, userId? } and address may be undefined. orgId and userId may also be undefined.
  • Otherwise, returns the smart account user from the store with type: "sca", or null if no user exists.

import { useConnectedUser } from "@account-kit/react";
 
const user = useConnectedUser();
 
if (user?.type === "eoa") {
  // EVM wallets expose `address`; Solana wallets expose `solanaAddress`.
  console.log("Connected EOA:", user.address ?? user.solanaAddress);
}

UseConnectedUserResult

The connected user, or null if no user is available. ref

Was this page helpful?