You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

commerce-kit

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commerce-kit

`commerce-kit` is a simple TypeScript library designed specifically for e-commerce applications built with Next.js. It provides a range of utilities to interact with products, categories, and orders, seamlessly integrating with Stripe for payment processi

0.0.40
latest
npmnpm
Version published
Weekly downloads
253
6.3%
Maintainers
2
Weekly downloads
 
Created
Source

commerce-kit

commerce-kit is a simple TypeScript library designed specifically for e-commerce applications built with Next.js. It provides a range of utilities to interact with products, categories, and orders, seamlessly integrating with Stripe for payment processing.

Built by Your Next Store.

Features

  • Product Browsing: Easily fetch and display products.
  • Category Management: Manage and retrieve product categories.
  • Order Handling: Create and manage customer orders.
  • Cart Operations: Add products to cart and retrieve cart details.
  • Stripe Integration: Built-in support for payment processing using Stripe.

Installation

Install the package via npm:

npm install commerce-kit

Usage

commerce-kit is intended for use with Next.js applications. Here's a simple example of how to use it to fetch and display products:

import * as Commerce from "commerce-kit";
import { formatMoney } from "commerce-kit/currencies";
import Image from "next/image";
import Link from "next/link";

export async function ProductList() {
  const products = await Commerce.productBrowse({ first: 6 });

  return (
    <ul>
      {products.map((product) => (
        <li key={product.id}>
          <Link href={`/product/${product.metadata.slug}`}>
            <article>
              {product.images[0] && (
                <Image src={product.images[0]} width={300} height={300} alt={product.name} />
              )}
              <h2>{product.name}</h2>
              {product.default_price.unit_amount && (
                <p>
                  {formatMoney({
                    amount: product.default_price.unit_amount,
                    currency: product.default_price.currency,
                    locale: "en-US",
                  })}
                </p>
              )}
            </article>
          </Link>
        </li>
      ))}
    </ul>
  );
}

Debugging

This library uses a custom logger to output debug information. To control the debug output, use the LOG_LEVEL environment variable. The following levels are supported:

  • ERROR – Critical issue for a specific request that needs immediate attention.
  • WARN – Something that should be reviewed eventually.
  • LOG – Details on regular operations.
  • DEBUG – Debug information, including time and timeEnd function outputs.

License

This project is licensed under the AGPL Version 3 license – see the LICENSE.md file for details.

Keywords

commerce

FAQs

Package last updated on 04 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts