Skip to main content
The Storefront SDK (@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

The CLI templates already include this dependency. Install it manually if you are integrating the SDK into an existing project.

Get an API key

Before creating the SDK client, generate a Storefront API key:
  1. Open the Crave Dashboard Developers page.
  2. Go to Developers > API Development.
  3. In Step 1 - API Keys, click Generate Your First API Key or Add Key.
  4. Copy the full token when the success dialog appears. It is only shown once.
  5. In Step 2 - Location IDs, copy the locationId for the restaurant location your storefront should load.
Use those values as 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 optional RequestConfig (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

Other helpers you can call on cart:
  • updateGratuity
  • setTable
  • setRoom
  • updateItemQuantity
  • delete (clears the cart)
Need recommended items? Call the /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 underlying http 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:
Refer to packages/storefront-sdk/src/types in the monorepo for the complete list.

Error handling

The SDK throws an ApiError whenever the API responds with a non-2xx status:
The thrown error includes 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.

Working alongside the REST docs

Each SDK method corresponds one-to-one with a REST endpoint documented in the Storefront API reference. Use the SDK for JavaScript/TypeScript apps and the REST examples for other platforms; the payloads and response shapes are identical. Ready to put it all together? Follow the Build a Custom Storefront guide for an end-to-end walkthrough.