Hiyve Components - v1.0.0
    Preparing search index...
    • Access authentication state including status, errors, and TFA state.

      Useful for building custom loading screens, error displays, or conditional rendering based on auth lifecycle.

      Returns {
          clearError: () => void;
          error: Error | null;
          isAuthenticated: boolean;
          isLoading: boolean;
          status: AuthStatus;
          tfaEvent: TfaRequiredEvent | null;
          tfaRequired: boolean;
      }

      { status, isAuthenticated, isLoading, error, tfaRequired, tfaEvent, clearError }

      function AuthGuard({ children }: { children: React.ReactNode }) {
      const { isLoading, isAuthenticated, error } = useAuthState();
      if (isLoading) return <Spinner />;
      if (error) return <p>Auth error: {error.message}</p>;
      if (!isAuthenticated) return <Navigate to="/login" />;
      return <>{children}</>;
      }