Prebit Developer Docs
Storefront Framework (Boron)

client/

Hooks, reserved for genuinely interactive state only.

"use client" — for cart and checkout, the two things that are genuinely interactive client-side state. Not for read-only product/ collection data — that's server/'s job.

<CartProvider>

Wrap your root layout once:

import { CartProvider } from "@prebit/boron/client";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <CartProvider>{children}</CartProvider>
      </body>
    </html>
  );
}

Shares cart state across every component calling useCart() instead of each call re-fetching independently.

useCart()

const { cart, loading, isOpen, add, remove, update, clear, refresh, open, close, toggle } = useCart();

Bearer cart-token auth (no OAuth, no cookies-as-session) — the token is persisted in localStorage and mirrored to a same-domain cookie so a Server Component/Server Action can read it too (see actions/). Money is already normalized paise→rupees.

useCheckout()

const { initiate } = useCheckout((event, data) => {
  // "initiated" | "success" | "failed" | "cancelled"
});

initiate({ mode: "embed" }); // "embed" (default) | "popup" | "redirect"

Hands off to the standalone prebit-checkout app. Default mode is an inline iframe overlay; the moment an order needs a real payment provider, prebit-checkout itself escapes to a real top-level page first — the payment provider never runs nested inside Boron's own iframe (see @prebit/boron's client/checkout-embed.ts source comments for the full 3DS/UPI-app-switch reasoning — this isn't incidental complexity).

initiate({ items: [...] }) — "Buy Now" — stages the given item(s) into a brand-new, isolated cart (never the visitor's real one), so it can never destroy or silently merge into what's already in their cart.

useCustomer()

Not implemented yet — reserved in the folder layout so the shape is future-proof, but calling it throws a clear "not implemented" error rather than silently returning nothing. Customer accounts are out of scope for this version.

<AnalyticsProvider>, track(), subscribe()

Heartbeat, Web Vitals, and a business-event bus (add_to_cart, checkout_started, product_view, purchase, custom events) — see the dedicated Analytics page.

On this page