commerce-js-integration

Return only this JSON shape.

14|3|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/tomtoto757/ecomm-ai-skills-hub --skill commerce-js-integration-tomtoto757
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: commerce-js-integration
Source: https://github.com/tomtoto757/ecomm-ai-skills-hub/tree/main/skills/platform-integrations-infrastructure/finsilabs/headless-modern/commerce-js-integration
Command: npx skills add https://github.com/tomtoto757/ecomm-ai-skills-hub --skill commerce-js-integration-tomtoto757

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adds full storefront commerce capabilities to static sites and simple frontends without requiring a heavy backend or a full e-commerce platform, enabling product display, cart lifecycle management, and payment capture with minimal infrastructure.

Core Features & Use Cases

  • Product fetching and display: list products, retrieve single products by permalink, and render structured product metadata and images.
  • Cart lifecycle management: create/retrieve carts, add/update/remove line items, empty and refresh carts, and surface total item counts for UI badges.
  • Secure checkout flow: generate time-limited checkout tokens, fetch live shipping options, capture orders server-side using the secret key, refresh the cart after successful capture, and integrate Stripe as the payment gateway.
  • Developer patterns: single module-level Commerce client, public key usage on client, secret key usage on server, HTML sanitization for rich product descriptions, and Next.js-compatible examples for static rendering and API routes.
  • Use case: ideal for MVPs, portfolio projects, or small catalogs (under ~1,000 products) where teams want headless commerce without operating a complex backend.

Quick Start

Create a Next.js product page that lists products with the Commerce.js public key, uses the client to manage a cart, generates a checkout token before checkout, and captures the order server-side with the secret key.

Frequently Asked Questions about commerce-js-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add headless commerce checkout to a static Next.js site?

You can add headless commerce checkout to a static Next.js site by using the Commerce.js SDK to fetch products, manage a cart lifecycle, generate a checkout token, and capture orders server-side via a Next.js API route.

How does cart lifecycle management work with Commerce.js?

Cart lifecycle management with Commerce.js works by creating and retrieving carts, adding or removing line items, emptying contents, and refreshing totals to update UI badges for accurate item counts.

Do I need a backend server to process Stripe payments with Commerce.js?

You do not need a full backend server to process Stripe payments with Commerce.js, but you must use a server-side Next.js API route to securely handle your secret key for order capture.

Can I use Commerce.js for a large product catalog with thousands of items?

Commerce.js is not ideal for large catalogs with thousands of items. It is designed for small catalogs under 1,000 products, making it suitable for MVPs, portfolios, and simple storefronts.

Why do product descriptions need HTML sanitization in a headless store?

Product descriptions need HTML sanitization in a headless store to safely render rich text. The integration uses DOMPurify sanitization to prevent XSS vulnerabilities when displaying structured HTML metadata.

What is the best way to structure public and secret keys for a Commerce.js integration?

The best way to structure keys is using standard Node.js environment variables: use the public key on the client for product fetching and the secret key exclusively on the server for secure order capture.