Prood
ApplicationsStorefront

Storefront

The customer-facing Next.js 16 storefront — catalog, cart, checkout redirect, and account management.

apps/storefront is the customer-facing application. It renders the product catalog, manages the shopping cart, redirects to the checkout app for payment, and provides customer account pages.

Port: 3000 · Framework: Next.js 16 (App Router) · Auth: Better Auth (customers)

Architecture

The storefront is a thin client of the Commerce API. It does not import @prood/commerce directly — all catalog, cart, and order operations go through @prood/api-client.

Drag to pan · Scroll to zoom

Key dependencies

PackageRole
@prood/api-clientTyped HTTP client to apps/api
@prood/typesDomain types, error helpers
@prood/uiProduct grid, cart drawer, hero banner, checkout stepper, etc.
better-authCustomer authentication

Tenant resolution

Every request resolves the active merchant from the Host header:

  1. Custom domain → tenant_domain table lookup
  2. {slug}.{NEXT_PUBLIC_PLATFORM_DOMAIN} → organization slug
  3. Fallback → DEFAULT_TENANT_ORG_ID (dev only)

The resolved tenant ID is forwarded to the API via the Host header. Catalog cache tags are scoped per tenant.

See Auth & tenant for implementation details.

Features

FeatureImplementation
Product catalogServer components + Cache Components ('use cache')
Category browsing/categories/[slug] with filtered product grid
SearchClient search palette → BFF /api/commerce/search
Shopping cartCookie-backed cart ID + BFF routes + React context
CheckoutServer action → place order → redirect to checkout app
Customer authBetter Auth email/password on /login, /register
Order history/account/orders via API (requires session)
Dark modenext-themes via @prood/ui

Configuration

VariablePurpose
COMMERCE_API_URLAPI base URL (default http://localhost:3005/v1)
DATABASE_URLAuth tables + tenant domain lookup
BETTER_AUTH_SECRET, BETTER_AUTH_URLCustomer auth
CHECKOUT_URLCheckout app redirect target
CHECKOUT_API_SECRETAuth header for session creation
DEFAULT_TENANT_ORG_IDDev fallback tenant
NEXT_PUBLIC_PLATFORM_DOMAINSubdomain tenant resolution

Next.js configuration

The storefront enables Cache Components:

// next.config.ts
export default {
  cacheComponents: true,
  transpilePackages: ['@prood/ui', '@prood/types'],
}

Catalog pages use 'use cache' with tenant-scoped tags from @prood/commerce. Cart, checkout, and account routes stay dynamic.

On this page