Skip to Content
devhelp shopDocs

Headless Storefronts & Storefront UI

Build custom React and Next.js storefronts using @devhelp/shop and @devhelp/storefront-ui.

devhelp shop is headless by default. Every hosted storefront on devhelp shop consumes the exact same public Storefront API and published packages available to external developers.

Packages for headless storefronts

  • @devhelp/shop: Typed Storefront API client, cart token persistence, money formatting (formatMoney), and Next.js cache tag helpers (@devhelp/shop/next).
  • @devhelp/storefront-ui: Composable React components for catalog grids, product buying controls (variant selection, gallery zoom, quick add), cart controls, checkout forms (with country-aware addresses and global E.164 phone validation defaulting to +92), breadcrumbs, and order status displays.

Typical Next.js App Router setup

  1. Create a Publishable Key in Settings → API keys (dh_pk_live_…) and add your storefront domain to the allowed origins list.
  2. Fetch catalog data in Server Components using createShopServer from @devhelp/shop/next.
  3. Mutate carts in Server Actions or Client Components with cookieCartStorage (httpOnly cookies) so cart tokens stay protected from page scripts.
  4. Revalidate on store changes by subscribing a Next.js webhook route to product.*, collection.*, site.published, store.updated, menu.updated, and page.*, verifying with @devhelp/shop/webhooks, and calling revalidateTag.

Checkout flow

  1. Add line items to a cart via shop.cart.add (REST: POST /storefront/v1/carts/{id}/lines).
  2. Set shipping address and E.164 phone number via shop.cart.setDetails and fetch rates with shop.cart.shippingOptions.
  3. Optionally apply a discount code (shop.cart.applyDiscountCode).
  4. Call shop.cart.checkout:
    • For Cash on Delivery, the order is placed immediately.
    • For Safepay, follow the returned payment handoff or embedded checkout flow on the merchant's own Safepay account.

On this page