Save sites with a slug, serve them at /s/slug, and route customers' own domains to the right site.
Publishing is just a flag. A sites table holds each site's spec, a unique slug and published = true/false. A dynamic route renders published sites; everything else returns 404.
app/s/[slug]/page.tsx
import { notFound } from "next/navigation";
import SiteRenderer from "@/components/SiteRenderer";
import { createClient } from "@/lib/supabase/server";
export default async function Published({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
const supabase = await createClient();
const { data } = await supabase.from("sites").select("spec, published").eq("slug", slug).maybeSingle();
if (!data?.published) notFound();
return <SiteRenderer spec={data.spec} />;
}
This lesson comes with a Velour plan
Every Academy lesson, code sample and Claude Code prompt is included with Publish and Growth, along with everything in the builder.