React Custom Hook for Firebase Auth
A reusable custom hook that manages Firebase authentication state with loading states and error handling.
import { useState, useEffect, useCallback, useMemo } from 'react';
import { User, onAuthStateChanged, signOut } from 'firebase/auth';
import { auth } from '../lib/firebase';
interface AuthState {
user: User | null;
loading: boolean;
error: string | null;
Optimized with useCallback and useMemo to prevent unnecessary re-renders