Function useAuthState

  • Accesses the current authentication state.

    Returns types.AuthState

    Example

    function AuthStateComponent() {
    const { authenticated, authenticating, identity, error } = useAuthState();

    return (
    <div>
    {authenticating ? 'Authenticating...' : ''}
    {error ? `Error: ${error.message}` : ''}
    {authenticated ? `User ${identity?.getPrincipal()} is authenticated.` : 'User is not authenticated.'}
    </div>
    );
    }