useUser

A React hook that returns the current user information, either from an External Owned Account (EOA) or from the client store. It uses the Alchemy account context and synchronizes with external store updates. The best way to check if user is logged in for both smart account contract users and EOA.

If using smart contract account, returns address of the signer. If only using smart account contracts then you can use useSignerStatus or useAccount to see if the account is defined.

Import

1import { useUser } from "@account-kit/react";

Usage

import { 
const useUser: () => UseUserResult

A React hook that returns the current user information, either from an External Owned Account (EOA) or from the client store. It uses the Alchemy account context and synchronizes with external store updates. The best way to check if user is logged in for both smart account contract users and EOA.

If using smart contract account, returns address of the signer. If only using smart account contracts then you can use useSignerStatus or useAccount to see if the account is defined.

useUser
} from "@account-kit/react";
import type {
type User = { email?: string; orgId: string; userId: string; address: Address; solanaAddress?: string; credentialId?: string; idToken?: string; claims?: Record<string, unknown>; }
User
} from "@account-kit/signer";
type
type UseUserResult = (User & { type: "eoa" | "sca"; }) | null
UseUserResult
= (
type User = { email?: string; orgId: string; userId: string; address: Address; solanaAddress?: string; credentialId?: string; idToken?: string; claims?: Record<string, unknown>; }
User
& {
type: "eoa" | "sca"
type
: "eoa" | "sca" }) | null;
const
const user: UseUserResult
user
=
function useUser(): UseUserResult

A React hook that returns the current user information, either from an External Owned Account (EOA) or from the client store. It uses the Alchemy account context and synchronizes with external store updates. The best way to check if user is logged in for both smart account contract users and EOA.

If using smart contract account, returns address of the signer. If only using smart account contracts then you can use useSignerStatus or useAccount to see if the account is defined.

useUser
();

Returns

UseUserResult The user information, including address, orgId, userId, and type. If the user is not connected, it returns null. ref