import Link from "next/link"; import { cookies } from "next/headers"; import type { SpaceConfig } from "@/lib/spaces"; const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000/api"; interface Product { slug: string; name: string; description: string; category: string; product_type: string; image_url: string; base_price: number; } async function getProducts(spaceId: string): Promise { try { const params = new URLSearchParams(); if (spaceId && spaceId !== "default") { params.set("space", spaceId); } const url = `${API_URL}/products${params.toString() ? `?${params}` : ""}`; const res = await fetch(url, { next: { revalidate: 60 } }); if (!res.ok) return []; return res.json(); } catch { return []; } } async function getSpaceConfig(spaceId: string): Promise { try { const res = await fetch(`${API_URL}/spaces/${spaceId}`, { next: { revalidate: 300 }, }); if (res.ok) return res.json(); } catch {} return null; } function getMockupType(productType: string): string { if ( productType.includes("shirt") || productType.includes("tee") || productType.includes("hoodie") ) return "shirt"; if (productType.includes("sticker")) return "sticker"; if (productType.includes("print")) return "print"; return "shirt"; } export default async function HomePage() { const cookieStore = await cookies(); const spaceId = cookieStore.get("space_id")?.value || "default"; const [products, space] = await Promise.all([ getProducts(spaceId), getSpaceConfig(spaceId), ]); const name = space?.name || "rSwag"; const isCustomSpace = spaceId !== "default" && !!space; return (
{/* ── Hero Section ──────────────────────────────────────── */}
Part of the rSpace Ecosystem

{isCustomSpace ? ( name ) : ( <> Community Merch,
On Demand )}

{isCustomSpace ? ( space?.description || "Custom merchandise for your community." ) : ( <> Create a{" "} Space for your community's merchandise. Design, upload, and sell{" "} print-on-demand{" "} swag — stickers, shirts, and more. )}

Browse the Shop Upload a Design
{/* ── How It Works ──────────────────────────────────────── */}
How It Works

rSwag in 30 Seconds

Upload your design,{" "} preview it on products, and order print-on-demand merch shipped worldwide.

{/* Step 1 */}

1. Upload a Design

Upload your own artwork or generate a unique design with AI. Transparent PNGs work best for clean product mockups. Your art, your merch.

{/* Step 2 */}

2. Pick Products

Choose from t-shirts, hoodies, stickers, posters, mugs, and more. See photorealistic mockups of your design on each product. Preview before you order.

{/* Step 3 */}

3. Ship Worldwide

Printful prints and ships each order on demand. No inventory, no waste — just quality merch delivered to your door. Printed fresh, shipped fast.

{/* ── Features Grid ─────────────────────────────────────── */}

Built for Communities

Everything you need to run a merch shop for your project or community

AI Design Studio

Generate unique designs with AI or upload your own artwork. Instant photorealistic mockups.

Community Spaces

Each community gets its own branded storefront with custom themes, logos, and product catalog.

Zero Inventory

Print-on-demand means no upfront costs, no warehouse, no waste. Items are printed fresh per order.

Realistic Mockups

See your design on real product photos via Printful's mockup engine. No guessing how it'll look.

Secure Payments

Pay with Mollie — credit card, iDEAL, PayPal, and more. European data residency for privacy.

rSpace Ecosystem

Part of the r* suite — integrates with rVote, rWork, rMaps, and more collaborative tools.

{/* ── Featured Products ─────────────────────────────────── */} {products.length > 0 && (

Featured Products

Print-on-demand — fulfilled by Printful, shipped worldwide.

{products.slice(0, 6).map((product) => (
{product.name}
{product.product_type}

{product.name}

{product.description}

${product.base_price.toFixed(2)} View Details →
))}
{products.length > 6 && (
View all {products.length} products →
)}
)} {/* ── CTA Section ───────────────────────────────────────── */}
Join the rSpace Ecosystem

Ready to launch your community's merch?

Create a Space for your project, upload your designs, and let your community order swag — all powered by print-on-demand.

Get Started Browse the Demo
); }