{ 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}</>;
}
Access authentication state including status, errors, and TFA state.
Useful for building custom loading screens, error displays, or conditional rendering based on auth lifecycle.