Skip to content
IC Reactor

useUserPrincipal

useUserPrincipal is a convenience hook that returns the signed-in user’s Principal, or null while signed out. A signed-out session still holds an anonymous identity, and the hook does not return its principal.

import { useUserPrincipal } from "./reactor/hooks"
function UserBadge() {
const principal = useUserPrincipal()
if (!principal) return <span>Signed out</span>
return <span>{principal.toText().slice(0, 12)}...</span>
}
Type Description
Principal | null The signed-in user’s Principal, or null while signed out.