@craveup/storefront-sdk) gives you a thin, type-safe wrapper around the Crave Storefront API. It handles headers, timeouts, query strings, and customer auth tokens so you can focus on product workflows instead of request plumbing.
Installation
Creating a client
Client options
| Option | Required | Description |
|---|---|---|
baseUrl | ✅ | Root URL for the storefront API. Trailing slashes are trimmed automatically. |
apiKey | ⚠️* | Location-scoped API key. Required unless you inject it via headers on every call. |
getAuthToken | optional | Function that returns a customer JWT for authenticated flows (OTP login). Can resolve a promise for async storage. |
fetch | optional | Supply a custom fetch implementation (e.g. cross-fetch) when running in Node.js. |
defaultTimeoutMs | optional | Global request timeout in milliseconds (defaults to 10 000). |
apiKey, make sure you provide headers: { 'X-API-Key': '...' } in each request.
Using in Node.js / SSR environments
Request configuration
Every SDK method accepts an optionalRequestConfig (RequestOptions under the hood):
Available modules
createStorefrontClient exposes a set of grouped helpers. The most common ones are shown below; all public types are re-exported from the package.
Merchant
Locations & menus
Ordering sessions
Use ordering sessions to bootstrap a cart and persist metadata:Cart lifecycle
cart:
updateGratuitysetTablesetRoomupdateItemQuantitydelete(clears the cart)
/carts/{cartId}/products endpoint with the http helper.
Discounts
Analytics events
Direct HTTP access
Need an endpoint the SDK does not wrap yet? Use the underlyinghttp helper—it exposes get, post, put, patch, and delete with the same RequestConfig options.
Typed responses & imports
All DTOs used by the API are exported so you can declare explicit return types:packages/storefront-sdk/src/types in the monorepo for the complete list.
Error handling
The SDK throws anApiError whenever the API responds with a non-2xx status:
status, statusText, url, and the raw response body (where provided). Handle specific status codes to deliver better UX—for example, show a toast when a discount is no longer valid.