"use client"; import { signIn, useSession } from "next-auth/react"; import { useEffect, useState, Suspense } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { FaKey, FaInfoCircle, FaArrowRight } from "react-icons/fa"; import toast, { Toaster } from "react-hot-toast"; function HuggingFaceLogo({ className = "w-4 h-4" }) { return ( ); } function LoginContent() { const { data: session, status } = useSession(); const router = useRouter(); const searchParams = useSearchParams(); const next = searchParams.get("callbackUrl") || searchParams.get("next") || "/"; const [activeTab, setActiveTab] = useState("huggingface"); const [apiKeyInput, setApiKeyInput] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); useEffect(() => { if (status === "authenticated") router.push(next); }, [status, router, next]); const handleApiKeyLogin = async (e) => { e.preventDefault(); const key = apiKeyInput.trim(); if (!key) { toast.error("Please enter a valid API key or HF token"); return; } if (key.length < 5) { toast.error("Key appears too short"); return; } setIsSubmitting(true); try { const res = await signIn("credentials", { apiKey: key, redirect: false, callbackUrl: next }); if (res?.error) toast.error(res.error || "Failed to sign in"); else { toast.success("Signed in successfully!"); router.push(next); } } catch (err) { console.error(err); toast.error("An error occurred during authentication"); } finally { setIsSubmitting(false); } }; return (
🤗

Sign In to Hugging-c-ai

Choose your sign-in method: HuggingFace OAuth (recommended) or a custom API key / HF token.

{activeTab === "huggingface" ? (

✓ Free — get 50 starter credits

✓ HF Bucket — uploads save to your own HF dataset repo

✓ Gradio — call your own HF Spaces as LLM endpoints

We request scopes: openid, profile, email, repo:write, read. Your token is stored securely.

) : (
setApiKeyInput(e.target.value)} placeholder="hf_... | sk-... | sk-ant... | gsk_... | mu_..." className="w-full bg-bg-page border border-divider rounded-lg px-3.5 py-2.5 text-xs text-white placeholder-secondary-text/50 focus:outline-none focus:border-primary transition-colors" />
Auto-detects: HF · OpenAI · Anthropic · Groq · MuAPI Get HF Token →

âš¡ Use your own provider key. 0 website credits required.

)}
By signing in, you agree to our Terms. Tokens are encrypted at rest and never shared.
); } export default function Login() { return (
}>
); }