'use client'; import React, { useState, useEffect, ReactNode } from 'react'; interface ClientOnlyProps { children: ReactNode; fallback?: ReactNode; } /** * A wrapper component that only renders its children on the client side. * This helps prevent hydration errors when components use browser-only APIs. */ export default function ClientOnly({ children, fallback = null }: ClientOnlyProps) { const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); if (!mounted) { return <>{fallback}; } return <>{children}; }