Custom Hook

SiteAuth provides custom hook to help you manage authentication in your app.

useSiteAuth

A hook that provides authentication status and loading state.

import { useSiteAuth } from 'site-auth-react';
      
function Dashboard() {
  const { isAuthenticated, loading } = useSiteAuth();
  
  if (loading) {
      return <p>Loading...</p>;
  }
  
  if (!isAuthenticated) {
      return <p>You need to log in</p>;
  }
  
  return <p>Welcome to the dashboard!</p>;
}