useAuth
Hook for connection, disconnection and user data:
Usage
import { useAuth } from "@nfid/identitykit/react"
const { connect, disconnect, isConnecting, user } = useAuth()
Return values
user
{ principal: Principal, subaccount?: SubAccount} | undefined
Currently connected user principal and subaccount. Will be undefined until successfull connect.
isConnecting
boolean
Boolean representing wether user is connecting or not (signer selected, but user still not connected).
connect
(signerIdOrUrl?: string) => void
Function to trigger will open connect wallet modal wihout signerIdOrUrl
provided, will open signer
if signers includes one with provided id or provided value is valid signer url.
⚠️
Function will throw Error("Identitykit is not initialized yet")
until identitykit initializes. So make sure you disable your connect button in these cases.
disconnect
() => Promise<void>
Function to trigger manual disconnect