Prood
ApplicationsStorefront

Pages & Routes

Complete route map for the storefront application.

The storefront uses Next.js App Router with server components for catalog pages and client components for interactive cart/search UI.

Page routes

RouteTypeDescription
/ServerHome — hero banner, featured products, category links
/productsServerProduct listing with search query and sort params
/products/[slug]ServerProduct detail — gallery, options, variant selector, add-to-cart
/categories/[slug]ServerCategory-filtered product grid
/cartServer + ClientFull cart page with summary and checkout CTA
/checkoutServer + ClientCheckout form — customer info, shipping address, place order
/order-confirmationServerPost-payment order summary (query param: order ID)
/loginClientCustomer login form
/registerClientCustomer registration form
/accountServerAccount overview — profile info, recent orders
/account/ordersServerFull order history (requires auth)

Layout structure

Drag to pan · Scroll to zoom

API routes (BFF)

Local BFF routes proxy to the Commerce API where browser UX requires them:

RouteMethodsPurpose
/api/auth/[...all]*Better Auth handler
/api/commerce/cartGET, POSTRead existing cart or create new cart
/api/commerce/cart/itemsPOSTAdd item to cart
/api/commerce/cart/items/[itemId]PATCH, DELETEUpdate quantity or remove item
/api/commerce/cart/couponPOST, DELETEApply or remove coupon code
/api/commerce/searchGETProduct search for client search palette
/api/commerce/countriesGETCountry list for address forms

Why BFF routes exist

The cart ID is stored in an HTTP-only cookie (commerce_cart_id). Client-side cart operations (add to cart from product page, update quantity in drawer) cannot read this cookie directly — the BFF reads it and forwards the request to the API with the correct cart ID and tenant context.

Catalog reads do not need BFF routes — they are fetched server-side in React Server Components.

Components

Layout

ComponentFilePurpose
Headercomponents/header.tsxLogo, navigation, search, cart button, auth links
Footercomponents/footer.tsxStore links, legal, social
Searchcomponents/search.tsxSearch palette trigger
CartButtoncomponents/cart-button.tsxCart icon with item count badge
MobileMenucomponents/mobile-menu.tsxResponsive navigation drawer
ThemeTogglecomponents/theme-toggle.tsxLight/dark mode switch

Commerce

ComponentPurpose
ConnectedProductGridServer-fetched product grid with add-to-cart
AddToCartVariant-aware add-to-cart button
CheckoutFlowMulti-step checkout form

Providers

ProviderPurpose
AppProvidersTheme, toast (sonner), cart context wrapper
CartProviderClient cart state — syncs with BFF routes

Data fetching

Server components use fetchers from lib/commerce-data.ts:

// Example: product listing page
import { getProducts, getCategories } from '@/lib/commerce-data'

export default async function ProductsPage({ searchParams }) {
  const products = await getProducts({ query, sort, page })
  const categories = await getCategories()
  // ...
}

These fetchers wrap @prood/api-client and forward the request Host header for tenant resolution.

Caching

Catalog pages benefit from Next.js Cache Components:

  • Product listings: cached per tenant, 600s SWR
  • Categories: cached per tenant, 600s SWR
  • Store info: cached per tenant, 3600s SWR

Cart, checkout, and account pages are never cached — they depend on cookies and session state.

On this page