Use the hook useUserIsAnonymous to see if the user is anonymous or not.
const userIsAnonymous = useUserIsAnonymous()