# Headless commerce

> Run your own storefront on any stack with the Storefront API, the SDK and the Next.js starter.

Source: https://shopfa.st/docs/headless

Your ShopFast store already has a fast storefront with templates. Go headless when you want your own design system, an
app, a site on another stack, or ShopFast products inside something you already run. ShopFast keeps doing the hard
parts: the catalog, stock and keys, carts and discounts, checkout and payments, delivery, buyer accounts, taxes and
fraud checks.

## The pieces

| | |
| --- | --- |
| [Storefront API](https://shopfa.st/docs/headless/storefront-api) | The public API: catalog, search, cart, checkout, buyer accounts, support. Keys, CORS, caching and limits. |
| [Reference](https://shopfa.st/docs/headless/reference) | Every operation, generated from the live contract. |
| [JavaScript SDK](https://shopfa.st/docs/headless/sdk) | `@shopfast-sdk/client`: typed, no dependencies, browsers and servers. |
| [Next.js starter](https://shopfa.st/docs/headless/nextjs) | A complete store on the App Router you can deploy as it is. |
| [Headless checkout](https://shopfa.st/docs/headless/checkout) | Hand off to the hosted checkout, embed it, or use your own form. |
| [Buyer accounts](https://shopfa.st/docs/headless/accounts) | Email-code sign-in, orders, keys and downloads, subscriptions and the wallet. |
| [Cache and revalidation](https://shopfa.st/docs/headless/revalidation) | Edge caching and the `storefront.updated` webhook. |

## Five minutes to a product list

1. In **Settings → Headless & MCP → Storefront keys**, create a publishable key.
2. Fetch your products:

```ts
import { createStorefrontClient } from '@shopfast-sdk/client';

const shop = createStorefrontClient({ shop: 'your-store', key: 'sfpk_live_…' });
const { items } = await shop.products.list({ limit: 12 });
```

3. Add to a cart and send the buyer to checkout:

```ts
const cart = await shop.cart.create({ lines: [{ productId: items[0].id, quantity: 1 }] });
const { checkoutUrl } = await shop.cart.checkoutLink(cart.id);
location.href = checkoutUrl;
```

## Agents use the same API

AI shopping agents get the same catalog, cart and checkout through your store's
[public MCP server](https://shopfa.st/docs/ai/shopping-agents), with nothing to set up.
