Skip to main content
RapidDev - Software Development Agency
v0-integrationsNext.js API Route

How to Integrate BigCommerce with V0

To use BigCommerce with V0 by Vercel, generate your storefront UI in V0, then create Next.js API routes that proxy calls to BigCommerce's Storefront API (for browsing) and Management API (for admin tasks). Store your BIGCOMMERCE_STORE_HASH, BIGCOMMERCE_ACCESS_TOKEN, and BIGCOMMERCE_STOREFRONT_TOKEN in Vercel environment variables. This gives you a fully custom headless storefront with BigCommerce handling inventory, payments, and fulfillment.

What you'll learn

  • How to generate a product listing page and cart UI using V0 prompts
  • How to create Next.js API routes for the BigCommerce Storefront and Management APIs
  • How to fetch products, categories, and cart data from BigCommerce server-side
  • How to redirect users to BigCommerce's hosted checkout from a headless storefront
  • How to store BigCommerce credentials safely in Vercel environment variables
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate15 min read30 minutesE-commerceApril 2026RapidDev Engineering Team
TL;DR

To use BigCommerce with V0 by Vercel, generate your storefront UI in V0, then create Next.js API routes that proxy calls to BigCommerce's Storefront API (for browsing) and Management API (for admin tasks). Store your BIGCOMMERCE_STORE_HASH, BIGCOMMERCE_ACCESS_TOKEN, and BIGCOMMERCE_STOREFRONT_TOKEN in Vercel environment variables. This gives you a fully custom headless storefront with BigCommerce handling inventory, payments, and fulfillment.

Building a Headless BigCommerce Storefront with V0

BigCommerce's headless commerce model is one of its strongest differentiators: the platform handles the complex backend of e-commerce — inventory, payments, tax calculation, fulfillment, and customer accounts — while letting you build any frontend experience you want. V0 by Vercel is an ideal tool for generating that custom frontend. You can build a product catalog, search interface, and cart that look nothing like a standard BigCommerce theme, while the actual transaction and inventory logic stays in BigCommerce.

The integration uses two BigCommerce APIs. The Storefront API (REST or GraphQL) is designed for customer-facing operations: browsing products, managing the cart, and initiating checkout. The Management API handles catalog operations like creating and updating products, reading orders, and managing customers. Both APIs require authentication via an access token that you store in Vercel's environment variables.

For checkout, BigCommerce headless storefronts redirect customers to BigCommerce's hosted checkout page — a secure, PCI-compliant checkout flow that handles payment processing. This means you don't have to implement payment handling yourself; BigCommerce does it, and you get a redirect URL from the API to send customers there. This tutorial covers generating the storefront UI in V0, setting up API routes for products and cart, and deploying a fully functional headless storefront to Vercel.

Integration method

Next.js API Route

V0 generates the product listing, product detail, and cart UI components. You then create Next.js API routes that proxy requests to BigCommerce's REST and GraphQL APIs, keeping your access token server-side. The storefront fetches products, manages the cart, and handles checkout redirects through these API routes.

Prerequisites

  • A V0 account at v0.dev — the free tier is sufficient for this tutorial
  • A BigCommerce store — start a free trial at bigcommerce.com or use an existing store
  • A BigCommerce API account (V2/V3) with an access token — create one in your BigCommerce admin under Advanced Settings → API Accounts
  • Your BigCommerce store hash — visible in the URL of your admin panel (e.g., store-abc123)
  • A Vercel account (free) connected to your V0 project for environment variable storage and deployment

Step-by-step guide

1

Get Your BigCommerce API Credentials

Before writing any code, collect your BigCommerce API credentials from the admin panel. Log in to your BigCommerce store and go to Advanced Settings → API Accounts → Create API Account. Name it (e.g., V0 Headless Storefront) and select the API type as V2/V3 API Token. Under OAuth Scopes, you need at minimum: Products (read-only), Carts (modify), Checkouts (modify), Orders (read-only), and Content (read-only). Click Save and BigCommerce will show you the credentials once — save all three values immediately: the Client ID (starts with a long alphanumeric string), the Client Secret, and the Access Token. You also need your Store Hash, which is visible in the URL of your BigCommerce admin panel: it looks like store-xxxxxxxx in the URL https://store-xxxxxxxx.mybigcommerce.com/manage. For the Storefront API (customer-facing browsing), you'll also need a Storefront API Token if you want to use BigCommerce's GraphQL Storefront API. Generate one from Advanced Settings → Storefront API Tokens. The REST Management API is what most Next.js integrations use — it's the simpler approach and what this tutorial focuses on. Store your Store Hash and Access Token; you won't need the Client ID and Secret for server-to-server REST API calls.

Pro tip: Create separate API accounts for development and production with read-only scopes where possible — this limits the blast radius if a credential is accidentally exposed.

Expected result: You have the BigCommerce Store Hash (format: store-xxxxxxxx) and an Access Token with the appropriate scopes. Both are saved securely outside of any code files.

2

Generate the Storefront UI in V0

Open V0 at v0.dev and start with the product listing page — this is the foundation of your storefront. Describe the layout you want: grid or list view, filtering sidebar, sorting controls, and the card design for each product. Be specific about the component interface: the card should accept a product object with id, name, price, images, and a URL slug. V0 generates the component with Tailwind CSS and shadcn/ui. Use mock data with 6-9 sample products so the grid looks representative. Once the catalog looks right, generate the product card component separately with a V0 prompt — this component will be reused across the catalog and potentially a featured products section on the homepage. After the catalog and card, generate the cart sidebar component. The cart needs to be managed in a shared state context so that adding a product from the catalog updates the cart count in the header. Ask V0 to generate a CartProvider context component that wraps the app layout. V0 may generate a cart that stores state in localStorage — this is acceptable for a starting point, but you'll replace it with BigCommerce's server-side cart API in a later step for a persistent cart that survives browser refreshes. Design Mode (Option+D) lets you adjust the visual design without spending credits.

V0 Prompt

Create a product catalog page with a sticky left sidebar containing filter checkboxes and a right main area with a 3-column responsive product grid. Each ProductCard component shows: a square product image with object-cover, product name in semibold, price in larger font, star rating display (1-5), and an Add to Cart button. Show 9 mock products. Add a top bar with 'Showing X products', a sort select dropdown, and a grid/list view toggle. Make the layout responsive: 1 column on mobile, 2 on tablet, 3 on desktop.

Paste this in V0 chat

Pro tip: V0 works best when you generate each major UI section separately — catalog page, product card, cart sidebar, and checkout button. Then ask V0 to combine them into the final layout.

Expected result: A styled product catalog with filter sidebar, product grid, and mock data renders in V0 preview. The cart sidebar slides in smoothly. Cart item count shows in the header.

3

Create the BigCommerce API Routes

Create two API route files: one for product catalog operations and one for cart operations. The BigCommerce Management API base URL is https://api.bigcommerce.com/stores/{storeHash}/v3. All requests require the header X-Auth-Token set to your access token — this header stays server-side in your route handler and is never sent to the browser. For the products route, the GET handler fetches the product catalog with pagination. The BigCommerce V3 Products endpoint returns a data array of products with all fields including images, variants, and custom fields. Add query parameters for filtering: include_fields, limit, page, and keyword for search. For the cart route, you need POST to create a new cart or add items, GET to retrieve a cart by ID, PUT to update item quantities, and DELETE to remove items. BigCommerce cart IDs are UUIDs stored in a cookie on the client. When creating a cart for the first time, store the returned cart ID in a cookie so subsequent requests can retrieve the same cart. For checkout, fetch the cart's redirect_urls.checkout_url from the cart API and redirect the customer there — BigCommerce handles the rest. The checkout URL is a one-time-use URL that expires, so generate it fresh each time the customer clicks checkout.

V0 Prompt

Update the product catalog to fetch data from GET /api/bigcommerce/products on component mount. Show a skeleton loading grid (9 gray placeholder cards) while fetching. When the Add to Cart button is clicked, call POST /api/bigcommerce/cart with { productId, quantity: 1 } and store the returned cartId in localStorage. Update the cart item count in the header. Display a toast notification 'Added to cart!' on success.

Paste this in V0 chat

app/api/bigcommerce/products/route.ts
1import { NextRequest } from 'next/server';
2
3const STORE_HASH = process.env.BIGCOMMERCE_STORE_HASH!;
4const ACCESS_TOKEN = process.env.BIGCOMMERCE_ACCESS_TOKEN!;
5const BC_BASE = `https://api.bigcommerce.com/stores/${STORE_HASH}/v3`;
6
7const bcHeaders = {
8 'X-Auth-Token': ACCESS_TOKEN,
9 'Content-Type': 'application/json',
10 Accept: 'application/json',
11};
12
13export async function GET(request: NextRequest) {
14 const { searchParams } = new URL(request.url);
15 const page = searchParams.get('page') ?? '1';
16 const keyword = searchParams.get('keyword') ?? '';
17 const limit = searchParams.get('limit') ?? '12';
18
19 const params = new URLSearchParams({
20 limit,
21 page,
22 include: 'images,variants',
23 ...(keyword && { keyword }),
24 });
25
26 const res = await fetch(`${BC_BASE}/catalog/products?${params}`, {
27 headers: bcHeaders,
28 next: { revalidate: 60 }, // Cache for 60 seconds with ISR
29 });
30
31 if (!res.ok) {
32 return Response.json({ error: 'Failed to fetch products' }, { status: res.status });
33 }
34
35 const { data, meta } = await res.json();
36 return Response.json({ products: data, pagination: meta.pagination });
37}

Pro tip: Add next: { revalidate: 60 } to your product fetch to cache results for 60 seconds using Next.js ISR — this dramatically reduces BigCommerce API calls for popular catalog pages.

4

Implement the Cart API Route

Create a separate API route for cart operations at app/api/bigcommerce/cart/route.ts. Cart management is the most complex part of a headless BigCommerce storefront because you need to track the cart ID across requests. BigCommerce creates a cart with a UUID when you first add an item — you must store this UUID on the client (in localStorage or a cookie) and send it with every subsequent cart operation. The POST handler handles two cases: creating a new cart (no cartId) and adding to an existing cart (cartId provided). For a new cart, POST to /v3/carts with line_items containing the product ID, variant ID, and quantity. BigCommerce returns the full cart object including the cart ID. For adding to an existing cart, POST to /v3/carts/{cartId}/items. The GET handler retrieves the full cart by ID and also generates a fresh checkout redirect URL. The checkout URL is critical — fetch it from /v3/carts/{cartId}/redirect_urls to get a one-time URL that sends the customer to BigCommerce's PCI-compliant checkout. The DELETE handler removes items from the cart using the line item ID. Always include variant_id in add-to-cart requests even for products without variants — use the default variant ID from the product's variants array. BigCommerce returns a 422 error if variant_id is missing for products that require it.

app/api/bigcommerce/cart/route.ts
1import { NextRequest } from 'next/server';
2
3const STORE_HASH = process.env.BIGCOMMERCE_STORE_HASH!;
4const ACCESS_TOKEN = process.env.BIGCOMMERCE_ACCESS_TOKEN!;
5const BC_BASE = `https://api.bigcommerce.com/stores/${STORE_HASH}/v3`;
6
7const bcHeaders = {
8 'X-Auth-Token': ACCESS_TOKEN,
9 'Content-Type': 'application/json',
10 Accept: 'application/json',
11};
12
13export async function POST(request: NextRequest) {
14 const { cartId, productId, variantId, quantity = 1 } = await request.json();
15
16 if (cartId) {
17 // Add to existing cart
18 const res = await fetch(`${BC_BASE}/carts/${cartId}/items`, {
19 method: 'POST',
20 headers: bcHeaders,
21 body: JSON.stringify({
22 line_items: [{ product_id: productId, variant_id: variantId, quantity }],
23 }),
24 });
25 const cart = await res.json();
26 return Response.json(cart.data ?? cart, { status: res.ok ? 200 : res.status });
27 }
28
29 // Create a new cart
30 const res = await fetch(`${BC_BASE}/carts`, {
31 method: 'POST',
32 headers: bcHeaders,
33 body: JSON.stringify({
34 line_items: [{ product_id: productId, variant_id: variantId, quantity }],
35 }),
36 });
37 const cart = await res.json();
38 return Response.json(cart.data ?? cart, { status: res.ok ? 201 : res.status });
39}
40
41export async function GET(request: NextRequest) {
42 const { searchParams } = new URL(request.url);
43 const cartId = searchParams.get('cartId');
44 if (!cartId) return Response.json({ error: 'cartId required' }, { status: 400 });
45
46 const [cartRes, redirectRes] = await Promise.all([
47 fetch(`${BC_BASE}/carts/${cartId}?include=redirect_urls`, { headers: bcHeaders }),
48 fetch(`${BC_BASE}/carts/${cartId}/redirect_urls`, { method: 'POST', headers: bcHeaders }),
49 ]);
50
51 const cartData = await cartRes.json();
52 const redirectData = await redirectRes.json();
53
54 return Response.json({
55 cart: cartData.data,
56 checkoutUrl: redirectData.data?.checkout_url,
57 });
58}

Pro tip: Always fetch a fresh checkout_url immediately before redirecting the customer — the URL is single-use and expires quickly, so do not store it in state.

5

Add Credentials to Vercel and Deploy

Add your BigCommerce credentials to Vercel's environment variable system. Connect your V0 project to GitHub using V0's Git panel, then open your Vercel project at vercel.com/dashboard. Go to Settings → Environment Variables and add: BIGCOMMERCE_STORE_HASH (your store-xxxxxxxx value), BIGCOMMERCE_ACCESS_TOKEN (your access token from the API account), and optionally BIGCOMMERCE_STOREFRONT_TOKEN if you plan to use the GraphQL Storefront API. Check all three environment scopes: Production, Preview, and Development. None of these should use the NEXT_PUBLIC_ prefix — all BigCommerce API calls must be server-side. Click Save after each variable, then trigger a redeployment. For local development, create .env.local with the same variables. After deployment, test the full flow: load the catalog page (products should appear from BigCommerce), add a product to the cart, verify the cart shows the correct item, and click checkout to confirm the redirect to BigCommerce's hosted checkout page. One important V0 limitation: the browser preview cannot call the BigCommerce API, so all API testing must happen on a Vercel deployment. Use Vercel preview deployments (created automatically for each GitHub branch push) to test API integrations before merging to production. For production BigCommerce stores with complex catalog structures, custom fields, and multi-channel configurations, RapidDev can help architect the full headless storefront integration.

.env.local
1# .env.local never commit to git
2BIGCOMMERCE_STORE_HASH=store-xxxxxxxx
3BIGCOMMERCE_ACCESS_TOKEN=your_access_token_here
4BIGCOMMERCE_STOREFRONT_TOKEN=your_storefront_token_here

Pro tip: Test with a Vercel preview deployment before merging to main — this gives you a live URL with real BigCommerce API access for full end-to-end testing without touching production.

Expected result: The production storefront shows real BigCommerce products. Adding to cart creates a BigCommerce cart and stores the cart ID. The checkout button redirects to BigCommerce's hosted checkout page.

Common use cases

Custom Product Catalog Page

Build a visually unique product listing page that fetches your BigCommerce catalog and renders products in a custom grid layout with filters, sorting, and search. The design goes far beyond any standard BigCommerce theme while the product data stays managed in your BigCommerce admin.

V0 Prompt

Create a product catalog page with a two-column layout: a left sidebar with filter checkboxes for category and price range, and a right content area with a 3-column product grid. Each product card shows a product image, name, price, and an Add to Cart button. Add a top bar with a sort dropdown and item count. The component should accept a products prop with array of { id, name, price, imageUrl, url } objects.

Copy this prompt to try it in V0

Persistent Shopping Cart Sidebar

Add a slide-out cart drawer that appears when users add products. The cart shows line items with quantities and prices, supports quantity adjustments, and includes a Checkout button that redirects to BigCommerce's hosted checkout. Cart state persists across page navigations.

V0 Prompt

Create a shopping cart sidebar that slides in from the right side of the screen when open. Show a list of cart items, each with a product thumbnail, name, quantity stepper (minus/plus buttons), unit price, and a remove button. Show a subtotal at the bottom with a prominent Checkout button. Add a cart icon in the header with an item count badge. Manage cart open/close state with a Context provider.

Copy this prompt to try it in V0

Product Detail Page with Variant Selector

Generate a product detail page with an image gallery, variant selector (size/color), quantity input, and add-to-cart functionality. Selecting a variant updates the displayed price and image. The add-to-cart action calls your API route to add the specific variant to the BigCommerce cart.

V0 Prompt

Build a product detail page with a left column showing a main product image and thumbnail row below it, and a right column showing product name, price, a color swatch selector, a size dropdown, a quantity stepper, and a large Add to Cart button. When a variant is selected, update the main image and price. Accept a product prop with { id, name, price, images, variants: [{ id, sku, optionValues, price }] }.

Copy this prompt to try it in V0

Troubleshooting

API returns 401 Unauthorized when fetching products

Cause: The BIGCOMMERCE_ACCESS_TOKEN is missing, expired, or set to the wrong environment scope in Vercel. The X-Auth-Token header is required for every Management API request.

Solution: Verify BIGCOMMERCE_ACCESS_TOKEN is set in Vercel Dashboard → Settings → Environment Variables for all three scopes. If the token was recently regenerated in BigCommerce, update it in Vercel and redeploy. Check that the store hash matches the store where the API account was created.

Adding to cart returns 422 Unprocessable Entity

Cause: BigCommerce requires a variant_id even for products with no user-selectable variants. If the variant_id is missing or is the wrong format (string instead of number), the cart API rejects the request.

Solution: Include the variant_id in every add-to-cart request. For products with no variants, use the product's default variant ID from the variants array returned by the products API. Cast variant_id to a number — the BigCommerce API expects integers, not strings.

typescript
1// Always include variantId — use the first variant for products with no options
2const variantId = product.variants?.[0]?.id ?? product.base_variant_id;
3body: JSON.stringify({ line_items: [{ product_id: productId, variant_id: variantId, quantity }] })

Product images return 404 after fetching from BigCommerce API

Cause: BigCommerce image URLs include a CDN path that may change or require a specific size suffix. Very large images also have different URL patterns than standard catalog images.

Solution: Use the url_thumbnail or url_standard field from the images array rather than the raw url_zoom field. These provide appropriately sized CDN URLs. If images still 404, check the image configuration in your BigCommerce store settings.

typescript
1// Use url_standard for catalog display instead of the raw url
2const imageUrl = product.images?.[0]?.url_standard ?? product.images?.[0]?.url_thumbnail;

Products fetch works but cart checkout URL is expired or invalid

Cause: BigCommerce checkout redirect URLs are single-use and expire within a few minutes. If you generate the URL when the cart is first fetched and store it in state, it may be expired by the time the customer clicks checkout.

Solution: Always generate a fresh checkout URL immediately before redirecting the customer. Make an additional API call to /v3/carts/{cartId}/redirect_urls at the moment the checkout button is clicked, then redirect to the returned checkout_url — do not cache this URL.

Best practices

  • Always proxy BigCommerce API calls through Next.js API routes — never expose your X-Auth-Token in client-side JavaScript
  • Use Next.js ISR (next: { revalidate: 60 }) on product catalog API routes to cache responses and reduce BigCommerce API calls for high-traffic storefronts
  • Store the BigCommerce cart ID in localStorage or a cookie on the client and send it with every cart API request — BigCommerce uses this to identify the customer's cart
  • Always fetch a fresh checkout redirect URL immediately before sending the customer to checkout — the URL is single-use and expires quickly
  • Include variant_id in every add-to-cart request even for simple products without user-selectable options — use the product's base variant ID as the fallback
  • Use BigCommerce's native checkout for payment processing — implementing a custom checkout is complex and requires PCI compliance certification
  • Create separate API accounts with minimum required scopes for development and production to limit credential exposure risk

Alternatives

Frequently asked questions

Does V0 have built-in BigCommerce support?

V0 does not have native BigCommerce support or a one-click Marketplace integration. You need to add the API routes and environment variable setup yourself as described in this tutorial. V0 is excellent for generating the storefront UI components, but the BigCommerce API wiring requires manual code.

What is headless commerce and why use it with BigCommerce?

Headless commerce means decoupling the frontend (what customers see) from the backend (inventory, payments, orders). BigCommerce handles all the complex commerce logic while you build a completely custom Next.js frontend with V0. You get full design freedom without building payment processing or inventory management yourself. BigCommerce supports headless natively with dedicated APIs for this use case.

Do I need to handle payments in my Next.js app?

No. BigCommerce's headless model uses a hosted checkout URL — when customers click Checkout, they're redirected to BigCommerce's PCI-compliant checkout page that handles payment processing, tax calculation, and order confirmation. Your Next.js app only needs to manage the cart and redirect to the BigCommerce checkout URL. This is a major advantage over building a custom checkout.

How do I handle product variants like sizes and colors?

When fetching product details with include=variants, BigCommerce returns a variants array with each combination of options. Build a variant selector UI in V0 that lets users pick their options, then map their selection to the matching variant's ID. Send this variant ID in your add-to-cart API call. V0 can generate a swatch and dropdown selector component if you describe the variant structure.

Why does the checkout redirect fail in V0's preview?

V0's browser preview sandbox cannot make outbound API calls to BigCommerce, so the cart API and checkout redirect won't work in the preview. This is a V0 platform limitation — test all e-commerce functionality using a Vercel preview deployment URL after pushing your code to GitHub.

Can I use BigCommerce's GraphQL Storefront API instead of REST?

Yes. BigCommerce offers a GraphQL Storefront API that's optimized for customer-facing operations. It uses a Storefront API Token (different from the Management API token) and queries product data more efficiently than the REST API for complex frontends. Set up BIGCOMMERCE_STOREFRONT_TOKEN in your Vercel environment variables and use a GraphQL client like graphql-request in your API route to query it.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.