"use client"; import { IconCheck, IconCopy, IconExternalLink, IconKey, } from "@tabler/icons-react"; import { motion } from "motion/react"; import { useRouter } from "next/navigation"; import { useCallback, useEffect, useState } from "react"; const steps = [ { number: "1", title: "Create a TMDB account", description: ( <> Head to{" "} themoviedb.org {" "} and sign up for a free account. ), }, { number: "2", title: "Request an API key", description: ( <> Go to{" "} Settings → API {" "} and request an API key. Choose “Developer” when asked. You need the{" "} API Read Access Token {" "} (the long one). ), }, { number: "3", title: "Add it to your environment", description: "Set the TMDB_API_KEY environment variable and restart Sofa.", }, ]; const envSnippets = [ { label: ".env file", code: "TMDB_API_KEY=your_api_read_access_token_here", }, { label: "Docker Compose", code: `environment: - TMDB_API_KEY=your_api_read_access_token_here`, }, { label: "Docker run", code: "docker run -e TMDB_API_KEY=your_token ...", }, ]; const sectionVariants = { hidden: { opacity: 0, y: 24 }, visible: { opacity: 1, y: 0, transition: { type: "spring" as const, stiffness: 200, damping: 24 }, }, }; export default function SetupPage() { const router = useRouter(); const [checking, setChecking] = useState(false); const [configured, setConfigured] = useState(null); const [copiedIdx, setCopiedIdx] = useState(null); const checkStatus = useCallback(async () => { setChecking(true); try { const res = await fetch("/api/setup/status"); if (res.ok) { const data = await res.json(); setConfigured(data.tmdbConfigured); if (data.tmdbConfigured) { // Key is now set — redirect to landing after a beat setTimeout(() => router.push("/"), 1500); } } } finally { setChecking(false); } }, [router]); useEffect(() => { checkStatus(); }, [checkStatus]); function copySnippet(idx: number, code: string) { navigator.clipboard.writeText(code); setCopiedIdx(idx); setTimeout(() => setCopiedIdx(null), 2000); } return ( {/* Header */}
Setup required

Connect to TMDB

Sofa uses{" "} The Movie Database {" "} for movie & TV metadata, posters, and streaming availability. You'll need a free API key to get started.

{/* Steps */} {steps.map((step, i) => (
{step.number}

{step.title}

{step.description}

{/* Show env snippets for step 3 */} {i === 2 && (
{envSnippets.map((snippet, idx) => (
{snippet.label}
                        {snippet.code}
                      
))}
)}
))}
{/* Status check */}
{configured === true ? (

TMDB API key detected

Redirecting you to Sofa...

) : (

After setting the key and restarting:

Click the button to verify your configuration

)}
); }