0.0.40 • Published 5 months ago

commerce-kit v0.0.40

Weekly downloads
-
License
AGPL-3.0-only
Repository
-
Last release
5 months ago

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.

0.0.40

5 months ago

0.0.38

7 months ago

0.0.39

7 months ago

0.0.37

8 months ago

0.0.36

8 months ago

0.0.35

9 months ago

0.0.21

11 months ago

0.0.22

10 months ago

0.0.23

10 months ago

0.0.24

10 months ago

0.0.25

10 months ago

0.0.30

9 months ago

0.0.31

9 months ago

0.0.32

9 months ago

0.0.33

9 months ago

0.0.34

9 months ago

0.0.26

10 months ago

0.0.27

10 months ago

0.0.28

10 months ago

0.0.29

9 months ago

0.0.20

11 months ago

0.0.17

11 months ago

0.0.18

11 months ago

0.0.19

11 months ago

0.0.14

11 months ago

0.0.15

11 months ago

0.0.16

11 months ago

0.0.13

11 months ago

0.0.10

12 months ago

0.0.11

12 months ago

0.0.12

11 months ago

0.0.1

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.5

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.0

12 months ago