Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

commerce-js-integration

БесплатноБез исполняемых скриптовНе проверен

Build a lightweight headless store using the Commerce.js SDK for product display, cart management, and checkout without a heavy backend

finsilabsот finsilabs★ 69 звёзд на GitHub

Об этом скилле

Commerce.js Integration

Overview

Commerce.js (Chec) is a headless commerce platform offering a JavaScript SDK that wraps its REST API for managing products, carts, checkouts, and orders. It is designed for developers who want to add commerce functionality to any website or JavaScript framework without the complexity of a full e-commerce platform. The SDK handles product fetching, cart lifecycle, checkout token creation, and order capture in a straightforward, promise-based API.

When to Use This Skill

  • When you want to add e-commerce to a static site or simple React/Vue/Svelte project quickly
  • When you don't need a complex backend and want a managed commerce API without server-side code
  • When building a portfolio project, MVP, or proof-of-concept headless store
  • When your catalog is small (under 1,000 products) and you don't need custom fulfillment logic
  • When you want a simple SDK without managing a full Shopify or commercetools environment

Prerequisites & Platform Notes

This skill is written for custom/headless storefronts (Node.js, Python, or similar backend). The code examples use TypeScript/Node.js and can be adapted to any stack.

Shopify: Shopify Hydrogen is Shopify's headless framework. MACH/composable patterns apply when using Shopify as the commerce backend with a custom frontend, or when mixing Shopify with other best-of-breed services. WooCommerce: WooCommerce can serve as a headless backend via its REST API and WPGraphQL. These patterns apply when decoupling the frontend from WordPress. Magento: Magento's GraphQL API and PWA Studio support headless architectures. These composable patterns apply to Magento as a backend service in a MACH stack.

You'll need:

  • Node.js 18+ (or adapt to your backend language)
  • Stripe account and API keys
  • An email sending service (SendGrid, AWS SES, or Postmark)

Core Instructions

  1. Install the SDK and initialize the client

    npm install @chec/commerce.js
    
    import Commerce from '@chec/commerce.js';
    
    // Public key is safe to expose in the browser
    const commerce = new Commerce(process.env.NEXT_PUBLIC_CHEC_PUBLIC_KEY, true); // true = debug mode
    

    Get your public API key from the Chec Dashboard under Developer → API keys.

  2. Fetch and display products

    // Fetch all products
    const {data: products} = await commerce.products.list({
      limit: 20,
      page: 1,
      sort_by: 'created',
      sort_direction: 'desc',
    });
    
    // Fetch a single product by permalink (slug)
    const product = await commerce.products.retrieve('my-product-slug', {type: 'permalink'});
    
    // Products include structured data
    console.log({
      id: product.id,
      name: product.name,
      price: product.price.formatted_with_symbol, // "$29.99"
      description: product.description,           // HTML string from Chec CMS
      image: product.image?.url,
      variants: product.variants,                 // Size, color options
    });
    

    React component example:

    import {useEffect, useState} from 'react';
    import Commerce from '@chec/commerce.js';
    
    const commerce = new Commerce(process.env.NEXT_PUBLIC_CHEC_PUBLIC_KEY!);
    
    export function ProductGrid() {
      const [products, setProducts] = useState<any[]>([]);
      const [loading, setLoading] = useState(true);
    
      useEffect(() => {
        commerce.products.list()
          .then(({data}) => setProducts(data))
          .finally(() => setLoading(false));
      }, []);
    
      if (loading) return <div>Loading...</div>;
    
      return (
        <div className="grid grid-cols-3 gap-6">
          {products.map(product => (
            <div key={product.id} className="border rounded-lg p-4">
              <img src={product.image?.url} alt={product.name} className="w-full h-48 object-cover" />
              <h2 className="mt-2 font-semibold">{product.name}</h2>
              <p className="text-gray-600">{product.price.formatted_with_symbol}</p>
              <AddToCartButton productId={product.id} />
            </div>
          ))}
        </div>
      );
    }
    
  3. Manage the cart

    Commerce.js stores the cart ID in localStorage automatically:

    // Get or create the current cart
    const cart = await commerce.cart.retrieve();
    
    // Add a product to the cart
    const updatedCart = await commerce.cart.add(productId, quantity, {
      // Optional: specify variant selections
      variantId: 'variant_id_here',
      optionId: 'option_id_here',
    });
    
    // Update line item quantity
    await commerce.cart.update(lineItemId, {quantity: 3});
    
    // Remove a line item
    await commerce.cart.remove(lineItemId);
    
    // Empty the cart
    await commerce.cart.empty();
    
    // Refresh the cart
    const refreshedCart = await commerce.cart.refresh();
    

    Cart state management with React Context:

    // context/cart-context.tsx
    import {createContext, useContext, useState, use
    
Полный SKILL.md на GitHub

Установить commerce-js-integration в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

claude-code
cursor
gemini-cli
copilot
codex-cli
kiro
opencode

Вложенные файлы

evals/cart-management-with-react-context-and-v/criteria.jsonevals/cart-management-with-react-context-and-v/task.mdevals/checkout-flow-with-token-generation-and-/criteria.jsonevals/checkout-flow-with-token-generation-and-/task.mdevals/product-catalog-rendering-with-safe-html/criteria.jsonevals/product-catalog-rendering-with-safe-html/task.mdtile.json

FAQ

Что делает скилл commerce-js-integration?

Build a lightweight headless store using the Commerce.js SDK for product display, cart management, and checkout without a heavy backend

Как установить скилл commerce-js-integration?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл commerce-js-integration запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить commerce-js-integration с