@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
Get an API key
Before creating the SDK client, generate a Storefront API key:- Open the Crave Dashboard Developers page.
- Go to Developers > API Development.
- In Step 1 - API Keys, click Generate Your First API Key or Add Key.
- Copy the full token when the success dialog appears. It is only shown once.
- In Step 2 - Location IDs, copy the
locationIdfor the restaurant location your storefront should load.
NEXT_PUBLIC_CRAVEUP_API_KEY and NEXT_PUBLIC_LOCATION_ID.
Creating a client
Client options
*If you omit
apiKey, the client looks for NEXT_PUBLIC_CRAVEUP_API_KEY. You can also pass the header per-request via headers: { 'X-API-Key': '...' }.
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.