import { IconExternalLink, IconKey } from "@tabler/icons-react";
import { redirect } from "next/navigation";
import { connection } from "next/server";
import { Suspense } from "react";
import { TmdbLogo } from "@/components/tmdb-logo";
import { isTmdbConfigured } from "@/lib/config";
import { CopyButton } from "./_components/copy-button";
import { RefreshButton } from "./_components/refresh-button";
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_READ_ACCESS_TOKEN environment variable and restart Sofa.",
},
];
const envSnippets = [
{
label: ".env file",
code: "TMDB_API_READ_ACCESS_TOKEN=your_api_read_access_token_here",
},
{
label: "Docker Compose",
code: `environment:
- TMDB_API_READ_ACCESS_TOKEN=your_api_read_access_token_here`,
},
{
label: "Docker run",
code: "docker run -e TMDB_API_READ_ACCESS_TOKEN=your_api_read_access_token_here ...",
},
];
export default function SetupPage() {
return (
);
}
export async function SetupContent() {
await connection();
if (isTmdbConfigured()) redirect("/");
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) => (
{snippet.label}
{snippet.code}
))}
)}
))}
{/* Status check */}
After setting the key and restarting:
Click the button to verify your configuration
This product uses the TMDB API but is not endorsed or certified by
TMDB.
);
}