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 cards into lists, discover rare cards, and connect with fellow enthusiasts in one beautiful platform.
Create custom lists, 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 binder.
Share your lists with the community, collaborate with friends, and discover amazing lists from other collectors.
Discover amazing lists from our community
{collection.cardCount} cards
{collection.description || 'A carefully curated list'}
Join thousands of collectors who trust Deck Hearth to manage their cards and lists.