import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import Link from 'next/link'; import { useAuth } from '../lib/use-auth.js'; import AnimatedFireLogo from '../components/AnimatedFireLogo'; export default function Home() { const { user, loading } = useAuth(); const router = useRouter(); const [featuredCollections, setFeaturedCollections] = useState([]); const [collectionsLoading, setCollectionsLoading] = useState(true); // If user is logged in, redirect to dashboard useEffect(() => { if (!loading && user) { router.push('/dashboard'); } }, [user, loading, router]); // Fetch featured collections for public display useEffect(() => { const fetchFeaturedCollections = async () => { try { const response = await fetch('/api/public/collections?limit=6'); if (response.ok) { const collections = await response.json(); setFeaturedCollections(collections); } } catch (error) { console.error('Error fetching featured collections:', error); } finally { setCollectionsLoading(false); } }; fetchFeaturedCollections(); }, []); // Show loading while checking auth if (loading) { return (
Loading...
The ultimate hub for trading card collectors. Organize your collection, discover rare cards, and connect with fellow enthusiasts in one beautiful platform.
Create custom collections, track card values, and organize by sets, rarity, or any system that works for you.
Search through thousands of cards across multiple TCGs. Find that missing piece for your collection.
Share your collections with the community, collaborate with friends, and discover amazing collections from other collectors.
Discover amazing collections from our community
{collection.cardCount} cards
{collection.description || 'A carefully curated collection'}
Join thousands of collectors who trust Deck Hearth to manage their trading card collections.