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
- Create a Publishable Key in Settings → API keys (
dh_pk_live_…) and add your storefront domain to the allowed origins list. - Fetch catalog data in Server Components using
createShopServerfrom@devhelp/shop/next. - Mutate carts in Server Actions or Client Components with
cookieCartStorage(httpOnly cookies) so cart tokens stay protected from page scripts. - Revalidate on store changes by subscribing a Next.js webhook route to
product.*,collection.*,site.published,store.updated,menu.updated, andpage.*, verifying with@devhelp/shop/webhooks, and callingrevalidateTag.
Checkout flow
- Add line items to a cart via
shop.cart.add(REST:POST /storefront/v1/carts/{id}/lines). - Set shipping address and E.164 phone number via
shop.cart.setDetailsand fetch rates withshop.cart.shippingOptions. - Optionally apply a discount code (
shop.cart.applyDiscountCode). - 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.