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 ) : ( <> Get Your Community{" "} Noticed
with{" "} (you) rMerch )}

{isCustomSpace ? ( space?.description || "Custom merchandise for your community." ) : ( <> A self-provisioned local design & print protocol that generates{" "} revenue (and attention!) for your community. )}

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

From Design to Revenue in Minutes

Create your community's merch, sell it on demand, and fund your community's work — no inventory, no risk.

{/* Step 1 */}

1. Upload or Create a Design

Upload your own artwork or generate a unique design with our AI studio. Logos, slogans, art — anything that represents your community. Your community's identity, on merch.

{/* Step 2 */}

2. Pick Products & Set Prices

Choose from t-shirts, hoodies, stickers, posters, mugs, and more. Set your markup — every dollar above cost goes directly into your community's funding stream. You set the margin, you keep the revenue.

{/* Step 3 */}

3. Ship Locally — Worldwide

Printful prints locally from the nearest fulfillment center — less shipping, less carbon. Delivered to your community members anywhere in the world. Local production, global reach.

{/* ── Community Revenue Model ───────────────────────────── */}

Merch That Funds Your Mission

Every purchase feeds revenue directly into your community's funding streams. No middlemen, no platform fees eating your margins.

{/* Revenue Flow */}

Direct Revenue Stream

Set your own margins. Printful handles production at cost, and the markup goes straight into your community's treasury, DAO, or project fund.

Production cost $9.25
Your price $29.99
Community revenue $20.74 per sale
{/* Community Benefits */}

Built for Communities

  • Branded Spaces — each community gets their own storefront with custom theme, logo, and catalog
  • Zero inventory risk — items printed on demand, no upfront costs for your community
  • Revenue routing — connect to rFunds, DAOs, or any wallet to stream merch revenue directly into community funding
  • Local production — Printful fulfills from the nearest center, reducing shipping distance and carbon footprint
{/* ── Features Grid ─────────────────────────────────────── */}

Everything Your Community Needs

Tools to design, sell, and ship merch that funds your collective work

AI Design Studio

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

Community Spaces

Each community gets its own branded storefront — custom domain, theme, and product catalog.

Revenue Streams

Merch revenue flows directly to your community — connect to rFunds, DAOs, treasuries, or any funding channel.

Realistic Mockups

See your design on real products via Printful's mockup engine before you ever commit to an order.

Local Fulfillment

Printed at the nearest Printful facility — shorter shipping distances, less carbon, faster delivery.

rSpace Ecosystem

Part of the r* suite — integrates with rFunds for treasury, rVote for design governance, and more.

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

Community Merch

Locally produced, print-on-demand — every sale supports the community.

{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 ───────────────────────────────────────── */}
Fund Your Community

Turn your community's identity into a revenue stream

Create a Space, upload your designs, and start selling merch that funds your community's work. Every sale flows directly into your community's funding channels.

Get Started Browse the Shop
); }