To integrate Salesforce Commerce Cloud (SFCC) with V0 by Vercel, use the Salesforce Commerce API (SCAPI) from Next.js API routes to fetch products, categories, and cart data for a headless storefront. V0 generates the React storefront UI; your API routes call SFCC's SCAPI endpoints using OAuth 2.0 PKCE tokens managed server-side in Vercel environment variables.
Build a Headless Storefront on Salesforce Commerce Cloud with V0
Salesforce Commerce Cloud powers e-commerce for many of the world's largest retail brands. Historically, SFCC required using the proprietary Storefront Reference Architecture (SFRA) for frontend rendering. With the introduction of the Salesforce Commerce API (SCAPI) and the Composable Storefront framework, SFCC now supports headless commerce — allowing any frontend framework, including V0-generated Next.js applications, to serve as the storefront while SFCC handles catalog, pricing, promotions, orders, and checkout.
The V0 + SFCC integration uses SCAPI's Shopper APIs, which provide REST endpoints for browsing products, managing carts, and completing checkout flows. Authentication uses OAuth 2.0 with PKCE for shopper sessions, or client credentials for server-to-server catalog reads. The V0-generated Next.js app calls these APIs through server-side route handlers that keep SFCC client credentials secure.
This guide focuses on the most common headless commerce scenario: building a product listing page and product detail page that read from SFCC's catalog. This is the foundation for full headless commerce. Note that SFCC requires a licensed instance — this guide assumes you have access to an SFCC sandbox or staging environment through your organization or partner.
Integration method
V0 generates the Next.js storefront UI — product listings, PDPs, cart, and checkout pages. Next.js API routes handle SFCC Shopper APIs authentication using the OAuth 2.0 PKCE flow and proxy product catalog and cart requests to the Salesforce Commerce API (SCAPI) endpoints, with credentials stored in Vercel environment variables. This pattern decouples the V0 frontend from SFCC's proprietary rendering engine.
Prerequisites
- Access to an SFCC sandbox instance with a Site ID configured (through your company or an SFCC partner)
- An SFCC API Client created in Account Manager (account.demandware.com) with shopper API access
- Your SFCC organization short code, instance hostname, site ID, and API client credentials
- A V0 account at v0.dev and a Vercel account for deployment
- Familiarity with OAuth 2.0 and REST APIs; SFCC enterprise experience is helpful but not required for basic catalog access
Step-by-step guide
Configure SFCC API Access in Account Manager
Configure SFCC API Access in Account Manager
SFCC API access is managed through Salesforce's Account Manager portal at account.demandware.com. Log in with your Salesforce credentials. Navigate to API Client under your organization. Create a new API Client (or use an existing one) — this generates a Client ID and Client Secret used for server-to-server authentication. Note your Organization Short Code — it is the 10-character alphanumeric code shown in Account Manager that identifies your SFCC organization (e.g., kv7kzm78). Your SFCC instance hostname will be in the format yoursite.sandbox.us01.dx.commercecloud.salesforce.com. The Site ID is the storefront site identifier configured in SFCC Business Manager (typically something like RefArch or your brand name). You also need to ensure the API client has the appropriate SCAPI permissions — in Business Manager (Administration → Site Development → Open Commerce API Settings), add entries allowing your client ID to access the Shop API endpoints including Products, Categories, Carts, and Orders. The specific JSON configuration for OCAPI/SCAPI permissions is available in Salesforce's headless commerce documentation and varies by SFCC version.
Pro tip: Use the Salesforce B2C Commerce Postman collection (available in the Salesforce developer documentation) to test your API credentials before writing code — it validates your setup faster than debugging in code.
Expected result: You have a valid SFCC API Client ID and Client Secret, your organization short code, instance hostname, and site ID ready for configuration.
Generate the Storefront UI with V0
Generate the Storefront UI with V0
Open V0 at v0.dev and describe your storefront pages. V0 excels at generating e-commerce UI — product grids, filter sidebars, breadcrumb navigation, product detail pages with image galleries, and cart drawers. Since you will connect this to real SFCC product data, include realistic product data shapes in your prompt so V0 generates components that match the actual field names. SFCC products have a productId, name, longDescription, price (in a prices array), and images (in an imageGroups array). Design your product listing page first, since it is the most important. Ask V0 to create a responsive grid layout with a mobile-first filter bar that collapses into a bottom sheet on small screens. Ask for a loading skeleton that matches the product card dimensions for perceived performance. V0 will also generate the API route stubs — app/api/sfcc/products/route.ts and app/api/sfcc/cart/route.ts. After the initial generation, use V0's Design Mode to adjust spacing and typography without spending credits, then deploy when the layout looks right.
Create a headless e-commerce storefront product listing page. Left sidebar has category filters and a price range slider. Main content shows a 3-column product grid with cards containing: product image, product name, price, and 'Add to Cart' button. Top shows a search bar and product count. Use a clean, minimal design with white background. Fetch products from /api/sfcc/products?categoryId=root. Show skeleton loading cards while data loads.
Paste this in V0 chat
Pro tip: Ask V0 to generate the product detail page (PDP) in the same prompt as the listing page — getting both pages in one generation saves credits and ensures visual consistency.
Expected result: V0 generates a full product listing page with filter sidebar, product grid, and skeleton loading. The API route stubs are created. The project deploys to a Vercel preview URL.
Create SFCC Authentication and Product API Routes
Create SFCC Authentication and Product API Routes
SFCC Shopper APIs require OAuth 2.0 PKCE authentication. For guest shopping sessions (the most common case for public storefronts), you use the 'guest' grant type to get a shopper JWT. This token is used in subsequent API calls. Create a shared authentication helper that gets a guest access token from SFCC's Shopper Login and API Access Service (SLAS). The token endpoint is POST /shopper/auth/v1/organizations/{orgId}/oauth2/token. For server-to-server calls like product catalog reads, you can use the simpler client credentials flow. Create app/api/sfcc/products/route.ts to fetch products from a category using the Shopper Products API. The Products API endpoint is GET /product/shopper-products/v1/organizations/{orgId}/products with query parameters for siteId, locale, currency, and an IDs list or GET /product/shopper-products/v1/organizations/{orgId}/categories/{categoryId}/products for browsing by category.
1import { NextResponse } from 'next/server';23const SFCC_HOST = process.env.SFCC_INSTANCE_HOST!;4const ORG_ID = `f_ecom_${process.env.SFCC_SHORT_CODE}_prd`;5const SITE_ID = process.env.SFCC_SITE_ID!;67async function getGuestToken(): Promise<string> {8 const response = await fetch(9 `https://${SFCC_HOST}/shopper/auth/v1/organizations/${ORG_ID}/oauth2/token`,10 {11 method: 'POST',12 headers: {13 'Content-Type': 'application/x-www-form-urlencoded',14 Authorization: `Basic ${Buffer.from(15 `${process.env.SFCC_CLIENT_ID}:${process.env.SFCC_CLIENT_SECRET}`16 ).toString('base64')}`,17 },18 body: new URLSearchParams({19 grant_type: 'client_credentials',20 channel_id: SITE_ID,21 }),22 }23 );24 const data = await response.json();25 return data.access_token;26}2728export async function GET(request: Request) {29 const { searchParams } = new URL(request.url);30 const categoryId = searchParams.get('categoryId') ?? 'root';31 const limit = searchParams.get('limit') ?? '24';3233 try {34 const token = await getGuestToken();35 const response = await fetch(36 `https://${SFCC_HOST}/product/shopper-products/v1/organizations/${ORG_ID}/categories/${categoryId}/products?siteId=${SITE_ID}&limit=${limit}&allImages=true`,37 {38 headers: { Authorization: `Bearer ${token}` },39 }40 );4142 const data = await response.json();4344 if (!response.ok) {45 return NextResponse.json({ error: data.title ?? 'SFCC error' }, { status: response.status });46 }4748 const products = (data.data ?? []).map((p: Record<string, unknown>) => ({49 id: p.productId,50 name: p.name,51 description: p.shortDescription,52 price: (p.price as number) ?? 0,53 image: ((p.imageGroups as Record<string, unknown>[])?.[0]?.images as Record<string, unknown>[])?.[0]?.link ?? '',54 }));5556 return NextResponse.json({ products, total: data.total ?? 0 });57 } catch (error) {58 console.error('SFCC products error:', error);59 return NextResponse.json({ error: 'Failed to fetch products' }, { status: 500 });60 }61}Pro tip: Cache the SFCC access token for the duration of its validity (usually 1800 seconds) in a module-level variable to avoid making a new OAuth request for every product API call. A token request on every call significantly increases latency.
Expected result: The products API route returns a JSON array of product objects with id, name, price, and image. Testing /api/sfcc/products?categoryId=root returns real SFCC catalog data.
Add Environment Variables in Vercel Dashboard
Add Environment Variables in Vercel Dashboard
Navigate to your Vercel project, go to Settings → Environment Variables, and add the SFCC configuration. SFCC_INSTANCE_HOST is your sandbox hostname without the https:// prefix (e.g., yoursite.sandbox.us01.dx.commercecloud.salesforce.com). SFCC_SHORT_CODE is the 10-character organization short code from Account Manager (e.g., kv7kzm78). SFCC_SITE_ID is the Site ID from SFCC Business Manager (e.g., RefArch or your site name). SFCC_CLIENT_ID and SFCC_CLIENT_SECRET are from the API Client you created in Account Manager. All five variables must be server-only (no NEXT_PUBLIC_ prefix) since they are used only in API routes. After adding variables, redeploy from the Deployments tab. For sandbox and production environments, you will have different SFCC_INSTANCE_HOST values — use Vercel's environment scopes to set sandbox credentials for Preview deployments and production credentials for Production deployments. Never use production SFCC credentials in Preview deployments as API calls affect live commerce data.
1# .env.local (local development only — set in Vercel Dashboard for deployments)2SFCC_INSTANCE_HOST=yoursite.sandbox.us01.dx.commercecloud.salesforce.com3SFCC_SHORT_CODE=kv7kzm784SFCC_SITE_ID=RefArch5SFCC_CLIENT_ID=your-api-client-id6SFCC_CLIENT_SECRET=your-api-client-secretPro tip: Use Vercel's separate Production and Preview environment scopes to point Preview deployments to your SFCC sandbox and Production deployments to your SFCC live instance — this prevents accidental writes to production data during development.
Expected result: All five SFCC environment variables are configured in Vercel Dashboard. The API route can now authenticate with SFCC and fetch product data.
Connect the Storefront UI and Implement Cart Functionality
Connect the Storefront UI and Implement Cart Functionality
With product fetching working, update your V0 UI to load real SFCC product data and implement cart functionality. The Add to Cart flow requires creating a basket (Shopper Baskets API: POST /checkout/shopper-baskets/v1/organizations/{orgId}/baskets) and then adding items to it (POST /checkout/shopper-baskets/v1/organizations/{orgId}/baskets/{basketId}/items). The basket ID should be stored in a cookie or in component state for the session. Create app/api/sfcc/cart/route.ts to handle basket operations. The cart API route needs to handle POST requests for adding items and GET requests for fetching the current basket. For production storefront implementations with custom checkout flows, order management, and payment integration, the complexity increases significantly. Many teams choose to use SFCC's own Composable Storefront (React PWA Kit) as the foundation and extend it with V0-generated components, rather than building the full checkout flow from scratch. RapidDev specializes in Salesforce Commerce Cloud headless implementations and can help design the complete cart-to-checkout architecture for production deployments.
Add cart functionality to the product listing. When 'Add to Cart' is clicked, POST { productId, quantity: 1 } to /api/sfcc/cart and update the cart count in the header. Store the basketId returned from the first add-to-cart call in component state and pass it with subsequent cart calls. Show a toast notification 'Added to cart' on success.
Paste this in V0 chat
Pro tip: SFCC's Shopper Baskets API requires consistent use of the same basketId throughout a session. Store it in a cookie set by the API route using a Set-Cookie response header so it persists across page navigations.
Expected result: The storefront displays real SFCC products. Clicking 'Add to Cart' creates an SFCC basket and adds the item. The cart count in the header updates to reflect the number of items.
Common use cases
Headless Product Catalog Storefront
Replace SFCC's default SFRA storefront with a custom Next.js frontend built with V0. Shoppers browse products rendered by V0's React components while product data, prices, and availability come live from SFCC's catalog via SCAPI.
Create an e-commerce product listing page with a filter sidebar on the left and a product grid on the right. Each product card shows the product image, name, price, and an 'Add to Cart' button. Include a header with a cart icon showing item count. Fetch products from /api/sfcc/products and the cart count from /api/sfcc/cart.
Copy this prompt to try it in V0
Personalized Promotions Display
Fetch SFCC promotions and loyalty data for authenticated customers and display personalized offers in a V0-built loyalty portal. Show promotion banners, available coupons, and points balance fetched from SFCC's Shopper Promotions API.
Build a customer loyalty page showing a points balance card, a list of available promotions with their discount amounts and expiry dates, and a coupon input form. Fetch promotions from /api/sfcc/promotions?customerId=XXX and display the results in cards.
Copy this prompt to try it in V0
B2B Catalog Portal
For SFCC B2B Commerce customers, build a custom buyer portal where business purchasers can browse the B2B catalog with contract pricing, place bulk orders, and view order history — all using V0's UI generation for fast frontend iteration.
Design a B2B catalog portal with a search bar, category navigation, and a product table view (showing SKU, description, contract price, and quantity input). Include a bulk order form at the bottom. Fetch catalog from /api/sfcc/b2b/catalog.
Copy this prompt to try it in V0
Troubleshooting
401 Unauthorized when calling SFCC Shopper APIs
Cause: The OAuth 2.0 token request is failing due to incorrect Client ID/Secret, or the API client does not have the required permissions configured in SFCC Business Manager.
Solution: Verify SFCC_CLIENT_ID and SFCC_CLIENT_SECRET match the credentials in Account Manager. In SFCC Business Manager → Administration → Site Development → Open Commerce API Settings, confirm the client ID is listed with appropriate permissions for the Shopper Products, Categories, and Baskets APIs.
404 Not Found for product or category endpoints despite correct configuration
Cause: The organization ID format in the URL is incorrect. SFCC's SCAPI organization ID follows a specific format: f_ecom_{shortCode}_{environment} — and the environment suffix varies by instance type.
Solution: Verify your org ID format. For sandbox instances it is typically f_ecom_{shortCode}_prd. Check the exact format in the Salesforce Commerce API documentation for your SFCC version, or use the Account Manager to confirm the organization ID. The short code is case-sensitive.
Products endpoint returns an empty data array for a valid category
Cause: The category may have no products assigned in SFCC Business Manager, or the site channel assignment for the API client is missing.
Solution: In SFCC Business Manager, verify the category has products assigned and they are set to 'online'. Also confirm that SFCC_SITE_ID matches the Site ID in Business Manager exactly (case-sensitive). Try the categoryId 'root' first to get all products, then narrow down to specific categories.
Images return as relative URLs instead of absolute URLs in the product response
Cause: SFCC image URLs in the API response are relative to the instance hostname unless allImages=true is passed and a base URL is configured.
Solution: Add allImages=true to the product API request query parameters. If images still return as relative paths, prepend the SFCC instance hostname to the image link field when mapping the response.
1image: link.startsWith('http') ? link : `https://${SFCC_HOST}${link}`Best practices
- Cache SFCC OAuth tokens for the duration of their validity (1800 seconds) to reduce authentication overhead — making a new token request for every API call doubles your latency
- Use SFCC sandbox credentials for Preview deployments and only promote production credentials to the Production environment scope in Vercel
- Store basket IDs in HTTP-only cookies (set by the API route) rather than localStorage to prevent XSS attacks from stealing active shopping sessions
- Implement Next.js Incremental Static Regeneration (ISR) for product catalog pages — cache product data for 60-300 seconds to reduce SFCC API load on high-traffic storefronts
- Never expose SFCC Business Manager credentials or admin API tokens in Vercel — only use Shopper API client credentials intended for frontend access
- Map SFCC's deeply nested product response to a flat internal product type in your API route — this decouples your frontend from SFCC's API schema changes
- Handle SFCC maintenance windows (typically Sunday nights) gracefully by implementing fallback cached content in your Next.js app
Alternatives
PrestaShop is an open-source e-commerce platform requiring self-hosting with a simpler API, making it better for SMB storefronts that don't need enterprise SFCC features.
BigCommerce offers a similar headless commerce API pattern but is significantly easier to set up and more affordable than SFCC for mid-market retailers.
Magento (Adobe Commerce) is comparable in enterprise scale to SFCC but is self-hosted or Adobe-managed, while SFCC is a pure SaaS offering.
Salesforce CRM connects to V0 for customer/order data analytics, while Salesforce Commerce Cloud specifically handles the e-commerce storefront and catalog.
Frequently asked questions
Do I need a Salesforce Commerce Cloud license to use the API?
Yes. SFCC is an enterprise platform that requires a licensing agreement with Salesforce. There is no free tier or public sandbox. Access is typically through your company's SFCC license or through a certified SFCC partner's sandbox environment.
What is the difference between OCAPI and SCAPI in Salesforce Commerce Cloud?
OCAPI (Open Commerce API) is SFCC's legacy REST API, while SCAPI (Salesforce Commerce API) is the modern API aligned with the Composable Storefront framework. New integrations should use SCAPI as Salesforce is investing in it for future development. OCAPI remains available for existing integrations but is not recommended for new headless projects.
Can I use V0 with SFCC's Composable Storefront (React PWA Kit)?
Yes. V0 generates standard React components that can be integrated into the SFCC Composable Storefront (which is also React-based). You can generate individual page components or sections with V0 and integrate them into the PWA Kit's page template structure. This hybrid approach gives you fast UI generation while leveraging the PWA Kit's SFCC-specific utilities.
Does this integration work with SFCC B2B Commerce?
The authentication and product catalog patterns are similar for B2B Commerce, but B2B has additional concepts like customer groups, price books, and contract pricing. The Account APIs and Buyer APIs handle B2B-specific features. The general pattern in this guide applies, but you will need to add B2B-specific API endpoints for buyer account management.
How do I handle product images hosted on SFCC's CDN?
SFCC serves product images through its own CDN (typically *.scene7.com or *.demandware.net). When you fetch products via the API, the image URLs are absolute URLs pointing to SFCC's CDN. You can use these URLs directly in your Next.js Image component — add the SFCC CDN hostname to your next.config.ts images.domains array to enable Next.js image optimization.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation