"use client"; import { useState, useEffect } from "react"; import Link from "next/link"; import { useSession, signIn } from "next-auth/react"; import { Search, Flame, Sparkles, TrendingUp, Loader2, Eye, MessageCircle, Filter, } from "lucide-react"; import toast, { Toaster } from "react-hot-toast"; export default function ExplorePage() { const { data: session, status } = useSession(); const [characters, setCharacters] = useState([]); const [loading, setLoading] = useState(true); const [search, setSearch] = useState(""); useEffect(() => { fetchCharacters(); }, []); const fetchCharacters = async () => { setLoading(true); try { const res = await fetch("/api/characters"); const data = await res.json(); if (data.characters) { const publicCustom = data.characters.filter((c) => c.isPublic && c.isCustom); setCharacters(publicCustom); } } catch (err) { console.error("Failed to load characters", err); toast.error("Failed to load characters"); } finally { setLoading(false); } }; const filtered = characters.filter((c) => { const matchesSearch = !search || c.name.toLowerCase().includes(search.toLowerCase()) || c.description.toLowerCase().includes(search.toLowerCase()) || c.personality.toLowerCase().includes(search.toLowerCase()); return matchesSearch; }); if (status === "loading") { return (
Discover personas crafted by other HuggingFace users. From historical figures to anime companions, find your next conversation partner — or publish your own creations to the community.
{search ? `No matches for "${search}". Try a different keyword.` : "Be the first to publish a public character to the marketplace!"}
+ Create Character{character.description}
{character.personality}
{session?.user ? ( ) : (