Wocart

Storefront SDK

@wocart/storefront is the storefront's connection to Wocart. It reads the store's catalog, delivery data and saved content, and it sends baskets, reviews, OTP codes and orders through the server that owns the rules.

Your Astro pages decide how the store looks. The SDK decides what is safe to read and send. Prices, stock, delivery fees, discounts and whether an order is accepted stay on the server.

A fixed storefront is a real choice

You do not need Wocart's editing tools to build a storefront. An Astro site with this SDK and your own components is complete. The optional Theme SDK adds merchant editing, saved page documents and preview.

Who this is for

If you are…Start with
New to WocartQuick start
Building a custom Astro storefront for one storeQuick start, then Astro actions and routes
Making an editable themeThe theme starter, then this SDK for the commerce data
Looking for one method or typeThe API reference

The guide begins with one working page and adds one area at a time. You can stop when your storefront does what you need.

What the SDK gives you

  • Typed reads. Products, categories, pages, menus, rates and config arrive as the shapes the server validated.
  • Predictable failures. Reads resolve to null, [] or {} and report the cause through onError. Writes return a result you can branch on.
  • A browser-safe root. The root entry has no client factory and no API key. Browser code imports it freely; the key stays on the server.
  • Astro adapters. Same-origin routes, the place-order form engine and the middleware that renders a refused form are ready to wire.
  • Browser helpers. The basket store, OTP state machine, image URLs for any media host, money formatting and the store's WhatsApp link are part of the package.

What you install

TerminalCode
npm install --save-exact @wocart/storefront@3.1.0 npm install zod

zod 4.x is a peer dependency. The package is ESM-only and its tooling needs Node 22.12 or newer. @wocart/storefront 3.x reads platform v7: a store updates its platform and its storefront together. The helpers under @wocart/storefront/astro are written for Astro 7; the rest of the package does not import Astro.

Four imports, one boundary

ImportRuns inWhat it holds
@wocart/storefrontBrowser and serverTypes, money and image helpers, reference data, basket, OTP machine, route paths, Meta payloads
@wocart/storefront/serverServer onlycreateStoreClient, preview and revalidation checks
@wocart/storefront/astroServer onlyresolveStoreRequest, createStorefrontRoutes, createProxyEndpoint, placeOrderInput, executePlaceOrder, runFormAction, lookupOrder, notFound
@wocart/storefront/review-mediaBrowser onlyPhoto resizing and voice recording for a review form

The store key has one home

@wocart/storefront/server holds the store API key. Never import it from a browser script, island or public variable. Browser code calls your own same-origin routes, and those routes call the SDK on the server.

What the client covers

NamespaceUse it for
configStore identity, languages, checkout policy and feature flags
productsProduct lists, product detail and reviews
collectionsA merchant's curated product lists and collection pages
categoriesCatalog navigation
pagesLegal and CMS pages, landing pages
menusThe store's navigation menus
pageDataThe saved page document for an editable theme
shippingDefault delivery prices per wilaya
geoWilayas and communes
cartServer re-pricing, coupons and delivery quotes
ordersOrder creation, OTP, abandoned checkout and tracking

What it does not do

The SDK does not render pages, store the browser's basket on the server, upload images, write page documents, or decide a theme's layout, copy and motion. It also does not make a stale browser price trustworthy.

Commerce rules live in the server. If a feature needs a new rule, change the server contract first, then use it here.

Guide map

PageWhat it covers
Quick startInstall, create the client, render a catalog and a product page
How it worksLayers, page types, results, caching and the security boundary
Store config and languagesStore settings, checkout policy, localization and theme text
Products and collectionsLists, detail, variants, offers, quantity pricing and categories
ReviewsRead reviews, prove a purchase, upload media and submit
Pages and menusLegal pages, navigation, landing pages and saved page documents
Basket and quotesThe browser basket, server validation, coupons and free delivery
Checkout and OTPPlace an order, verify a phone, track conversions and abandonment
Delivery and geographyDefault rates, real quotes, wilayas and communes
Money, images, WhatsApp and Meta eventsDisplay helpers and browser events that stay consistent
Astro actions and routesForm actions, middleware and the same-origin API
Preview and revalidationDraft previews and instant publish for editable themes
Testing a storefrontWhat to test, the definition of done and common mistakes
Public API surfaceEvery export per entry point, the client namespaces and the schemas

The API reference is generated from the published TypeScript declarations. This guide follows @wocart/storefront 3.1.0.