BigCommerce Headless Commerce
Before writing code
Fetch live docs:
- Fetch
https://www.catalyst.dev/ for Catalyst documentation
- Web-search
site:developer.bigcommerce.com headless for headless guide
- Web-search
site:github.com bigcommerce catalyst for Catalyst source and examples
Headless Architecture
What Headless Means for BigCommerce
Decouple the frontend from BigCommerce:
- BigCommerce serves as the commerce backend — catalog, orders, customers, payments
- Your custom frontend handles presentation — React, Next.js, Vue, etc.
- Communication via APIs — GraphQL Storefront API and REST API
- Checkout via Embedded Checkout or Custom Checkout (Checkout API + Payments API)
Why Headless
- Full frontend control (design, UX, performance)
- Use modern frameworks (Next.js, Remix, Astro)
- Composable architecture — mix BigCommerce with CMS, search, etc.
- Better performance with SSR/SSG/ISR
- Multi-channel frontend from single BigCommerce backend
Catalyst
What It Is
BigCommerce's official Next.js reference storefront:
- Built on Next.js 14+ with App Router
- Uses GraphQL Storefront API for data
- Tailwind CSS for styling
- Full-featured: PLP, PDP, cart, checkout, customer account, search
- Designed as a starting point to fork and customize
Getting Started
npx create-catalyst-storefront@latest my-store
Prompts for:
- BigCommerce store URL
- Channel ID
- Storefront API token
Project Structure
my-store/
├── app/ # Next.js App Router pages
│ ├── (default)/ # Default locale group
│ │ ├── page.tsx # Homepage
│ │ ├── product/ # Product pages
│ │ ├── category/ # Category pages
│ │ ├── cart/ # Cart page
│ │ └── account/ # Customer account
│ └── layout.tsx # Root layout
├── client/ # BigCommerce API client
│ ├── queries/ # GraphQL queries
│ └── mutations/ # GraphQL mutations
├── components/ # React components
├── lib/ # Utilities
├── public/ # Static assets
├── .env.local # Environment variables
├── next.config.js # Next.js config
├── tailwind.config.js # Tailwind config
└── package.json
Key Environment Variables
BIGCOMMERCE_STORE_HASH=your_store_hash
BIGCOMMERCE_ACCESS_TOKEN=your_access_token
BIGCOMMERCE_CHANNEL_ID=1
BIGCOMMERCE_STOREFRONT_TOKEN=your_storefront_token
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN=your_token
Data Fetching Patterns
Server Components (Recommended)
Fetch data in Next.js Server Components using the GraphQL client:
// app/product/[slug]/page.tsx
async function ProductPage({ params }: { params: { slug: string } }) {
const product = await getProduct({ path: `/${params.slug}` });
return <ProductDetail product={product} />;
}
Client-Side Fetching
For interactive features (cart, search-as-you-type):
- Use React hooks with the GraphQL Storefront API
- Storefront API token for unauthenticated requests
- Customer impersonation token for personalized data
Caching Strategy
- Static Generation (SSG) — product and category pages at build time
- Incremental Static Regeneration (ISR) — revalidate on interval or on-demand
- Server-Side Rendering (SSR) — cart, checkout, account pages
- Client-Side — search, cart updates, wishlist
Checkout in Headless
Embedded Checkout (Recommended)
Embed BigCommerce's checkout in your headless site:
- Create cart via API → get
redirect_urls.checkout_url
- Embed using
@bigcommerce/checkout-sdk embedCheckout()
- BigCommerce handles payment processing (no PCI scope)
Custom Checkout
Full API-driven checkout:
- Cart API → Checkout API → Orders API → Payments API
- Requires your own checkout UI
- Payment processing via Payments API (PCI implications if handling raw card data)
- Use tokenized payment methods to reduce PCI scope
Authentication in Headless
Customer Login
- Use the Customer Login API (JWT-based SSO) to create sessions
- Or implement custom auth and use Customer Impersonation Tokens for API access
- Catalyst includes built-in authentication flows
Session Management
- BigCommerce sessions are cookie-based on the BigCommerce domain
- For headless: use Customer Login API to set the cookie, then redirect to your domain
- Or manage auth entirely on your side and use impersonation tokens
Integration with Other Services
Composable Commerce Stack
BigCommerce + headless enables composable architecture:
- CMS: Contentful, Sanity, Strapi for content
- Search: Algolia, Bloomreach for product search
- Personalization: Dynamic Yield, Nosto for recommendations
- PIM: Akeneo, Salsify for product information
- OMS: for order management
Best Practices
- Start with Catalyst — fork and customize rather than building from scratch
- Use GraphQL Storefront API for frontend data fetching
- Use REST API for server-side operations (order management, catalog sync)
- Use Embedded Checkout to avoid PCI scope
- Implement ISR for product/category pages — balance freshness and performance
- Use customer impersonation tokens for personalized data
- Handle webhook events for real-time data sync
- Set up proper CORS configuration for Storefront API tokens
- Use environment variables for all credentials
Fetch the Catalyst documentation and BigCommerce headless guide for exact setup steps, GraphQL queries, and current best practices before implementing.
1---2name: bc-headless3description: Build headless commerce with BigCommerce — Catalyst (Next.js reference storefront), GraphQL Storefront API, server-side APIs, embedded checkout, and headless architecture patterns. Use when building decoupled storefronts or integrating BigCommerce as a headless backend.4---5
6# BigCommerce Headless Commerce
7
8## Before writing code
9
10**Fetch live docs**:
111. Fetch `https://www.catalyst.dev/` for Catalyst documentation
122. Web-search `site:developer.bigcommerce.com headless` for headless guide
133. Web-search `site:github.com bigcommerce catalyst` for Catalyst source and examples
14
15## Headless Architecture
16
17### What Headless Means for BigCommerce
18
19Decouple the frontend from BigCommerce:
20- BigCommerce serves as the **commerce backend** — catalog, orders, customers, payments
21- Your custom frontend handles **presentation** — React, Next.js, Vue, etc.
22- Communication via **APIs** — GraphQL Storefront API and REST API
23- Checkout via **Embedded Checkout** or **Custom Checkout** (Checkout API + Payments API)
24
25### Why Headless
26
27- Full frontend control (design, UX, performance)
28- Use modern frameworks (Next.js, Remix, Astro)
29- Composable architecture — mix BigCommerce with CMS, search, etc.
30- Better performance with SSR/SSG/ISR
31- Multi-channel frontend from single BigCommerce backend
32
33## Catalyst
34
35### What It Is
36
37BigCommerce's official Next.js reference storefront:
38- Built on **Next.js 14+** with App Router
39- Uses **GraphQL Storefront API** for data
40- **Tailwind CSS** for styling
41- Full-featured: PLP, PDP, cart, checkout, customer account, search
42- Designed as a starting point to fork and customize
43
44### Getting Started
45
46```bash
47npx create-catalyst-storefront@latest my-store
48```
49
50Prompts for:
51- BigCommerce store URL
52- Channel ID
53- Storefront API token
54
55### Project Structure
56
57```
58my-store/
59├── app/ # Next.js App Router pages
60│ ├── (default)/ # Default locale group
61│ │ ├── page.tsx # Homepage
62│ │ ├── product/ # Product pages
63│ │ ├── category/ # Category pages
64│ │ ├── cart/ # Cart page
65│ │ └── account/ # Customer account
66│ └── layout.tsx # Root layout
67├── client/ # BigCommerce API client
68│ ├── queries/ # GraphQL queries
69│ └── mutations/ # GraphQL mutations
70├── components/ # React components
71├── lib/ # Utilities
72├── public/ # Static assets
73├── .env.local # Environment variables
74├── next.config.js # Next.js config
75├── tailwind.config.js # Tailwind config
76└── package.json
77```
78
79### Key Environment Variables
80
81```
82BIGCOMMERCE_STORE_HASH=your_store_hash
83BIGCOMMERCE_ACCESS_TOKEN=your_access_token
84BIGCOMMERCE_CHANNEL_ID=1
85BIGCOMMERCE_STOREFRONT_TOKEN=your_storefront_token
86BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN=your_token
87```
88
89## Data Fetching Patterns
90
91### Server Components (Recommended)
92
93Fetch data in Next.js Server Components using the GraphQL client:
94```typescript
95// app/product/[slug]/page.tsx
96async function ProductPage({ params }: { params: { slug: string } }) {
97 const product = await getProduct({ path: `/${params.slug}` });
98 return <ProductDetail product={product} />;
99}
100```
101
102### Client-Side Fetching
103
104For interactive features (cart, search-as-you-type):
105- Use React hooks with the GraphQL Storefront API
106- Storefront API token for unauthenticated requests
107- Customer impersonation token for personalized data
108
109### Caching Strategy
110
111- **Static Generation (SSG)** — product and category pages at build time
112- **Incremental Static Regeneration (ISR)** — revalidate on interval or on-demand
113- **Server-Side Rendering (SSR)** — cart, checkout, account pages
114- **Client-Side** — search, cart updates, wishlist
115
116## Checkout in Headless
117
118### Embedded Checkout (Recommended)
119
120Embed BigCommerce's checkout in your headless site:
1211. Create cart via API → get `redirect_urls.checkout_url`
1222. Embed using `@bigcommerce/checkout-sdk` `embedCheckout()`
1233. BigCommerce handles payment processing (no PCI scope)
124
125### Custom Checkout
126
127Full API-driven checkout:
1281. Cart API → Checkout API → Orders API → Payments API
1292. Requires your own checkout UI
1303. Payment processing via Payments API (PCI implications if handling raw card data)
1314. Use tokenized payment methods to reduce PCI scope
132
133## Authentication in Headless
134
135### Customer Login
136
137- Use the Customer Login API (JWT-based SSO) to create sessions
138- Or implement custom auth and use Customer Impersonation Tokens for API access
139- Catalyst includes built-in authentication flows
140
141### Session Management
142
143- BigCommerce sessions are cookie-based on the BigCommerce domain
144- For headless: use Customer Login API to set the cookie, then redirect to your domain
145- Or manage auth entirely on your side and use impersonation tokens
146
147## Integration with Other Services
148
149### Composable Commerce Stack
150
151BigCommerce + headless enables composable architecture:
152- **CMS**: Contentful, Sanity, Strapi for content
153- **Search**: Algolia, Bloomreach for product search
154- **Personalization**: Dynamic Yield, Nosto for recommendations
155- **PIM**: Akeneo, Salsify for product information
156- **OMS**: for order management
157
158## Best Practices
159
160- Start with Catalyst — fork and customize rather than building from scratch
161- Use GraphQL Storefront API for frontend data fetching
162- Use REST API for server-side operations (order management, catalog sync)
163- Use Embedded Checkout to avoid PCI scope
164- Implement ISR for product/category pages — balance freshness and performance
165- Use customer impersonation tokens for personalized data
166- Handle webhook events for real-time data sync
167- Set up proper CORS configuration for Storefront API tokens
168- Use environment variables for all credentials
169
170Fetch the Catalyst documentation and BigCommerce headless guide for exact setup steps, GraphQL queries, and current best practices before implementing.