0.0.40 • Published 8 months ago

commerce-kit v0.0.40

Weekly downloads
-
License
AGPL-3.0-only
Repository
-
Last release
8 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

8 months ago

0.0.38

10 months ago

0.0.39

10 months ago

0.0.37

10 months ago

0.0.36

11 months ago

0.0.35

11 months ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.30

12 months ago

0.0.31

12 months ago

0.0.32

12 months ago

0.0.33

12 months ago

0.0.34

12 months ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

12 months ago

0.0.29

12 months ago

0.0.20

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.14

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.13

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.1

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.0

1 year ago