Developers

Sell your Sokko catalogue on a site you already run

@sokkoke/storefront-react is a headless React package. It gives you catalogue fetching, variant selection, a local basket and the handoff to checkout, with no styling layer. You write every element and class name.

Building with an agent? Take the page with you.
You need
A duka on Sokko, and its storefront id.
You do not need
An API key, a secret, or a server route of your own.
Sokko keeps
Checkout, payment, installments and delivery.
Quickstart
  1. Install

    React 18 or 19 is the only peer. The package is ESM only.

    npm install @sokkoke/storefront-react
  2. Create the client

    Once, at module scope. That one id is the whole setup.

    src/lib/store.js
    import {
      createStorefront,
      createCartStore
    } from '@sokkoke/storefront-react';
    
    export const storefront = createStorefront({
      storefrontId: 'your-storefront-id'
    });
    
    export const cart = createCartStore({
      namespace: 'your-site'
    });

    No API key and no server step. The package speaks only to Sokko public storefront endpoints.

    Your own id, with this snippet already filled in, is in your Sokko dashboard under Settings, Developers.

  3. Show your products

    Each hook is the headless version of one storefront component. You write the markup.

    src/StoreListing.jsx
    import { useCatalogue } from '@sokkoke/storefront-react';
    import { storefront } from './lib/store';
    
    export function StoreListing() {
      const { status, products } = useCatalogue(storefront);
    
      if (status !== 'ready') return <YourSkeleton />;
    
      return (
        <ul>
          {products.map((product) => (
            <ProductTile key={product.id} product={product} />
          ))}
        </ul>
      );
    }
  4. Hand off to checkout

    Buyers finish on Sokko, so payment, installments and delivery stay with us.

    src/BuyButton.jsx
    import {
      useProductPurchase,
      checkoutNoticeFor,
      formatPrice
    } from '@sokkoke/storefront-react';
    import { storefront, cart } from './lib/store';
    
    export function BuyButton({ product }) {
      const { selectedVariant, buyNow, checkoutStatus } =
        useProductPurchase(storefront, cart, product);
    
      const busy = checkoutStatus === 'working';
    
      return (
        <>
          <button
            disabled={!selectedVariant || busy}
            onClick={() => buyNow()}
          >
            {selectedVariant
              ? `Buy ${formatPrice(selectedVariant.priceAmount)}`
              : 'Select an option'}
          </button>
          <p>{checkoutNoticeFor(product)}</p>
        </>
      );
    }

    Checkout is a full navigation to a Sokko address. Tell buyers where they are going: an unannounced change of site reads as a broken link. checkoutNoticeFor(product) is written copy for exactly that, with the installment line added for items that qualify.

The four building blocks

Each hook is the headless version of one storefront component. Compose them under your own markup.

Store listinguseCatalogue
Fetch state (loading, ready, error) and your products.
Product tileuseProductTile
Primary image, srcSet, the "from" price, and whether the product has options.
Product pageuseProduct, useProductPurchase, useGallery, useRelatedProducts
Load and missing states, variant selection, clamped quantity, add to basket, buy now, gallery, and a related strip drawn from your own catalogue.
Cart dockuseCartDock
Drawer open and close, totals, checkout, and the modal contract: Escape closes, Tab cycles, focus returns, scroll locks.
Built with it

Charisma runs the package on their own site, in their own type and colour. The cards, the prices under them and the basket count in their header all come from the hooks.

The Charisma storefront: three merchandise cards in their own black and white design, a price under each title, and a basket count in the header.
Charisma, built with @sokkoke/storefront-react. Nothing on the page is Sokko’s design.
Full reference

Every hook, the API facts worth knowing, and a product page in about twenty lines are in the package readme.

@sokkoke/storefront-react on npm