npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

alla-cart

v1.0.6

Published

A simple, customizable shopping cart

Readme

AllaCart

AllaCart is a simple, customizable React shopping cart feature. Supply your own product data and the cart does the rest!

Demo

To see the cart in action, check out the example demo. Alla Cart demo

Install

npm install alla-cart

Usage

AllaCart is easy to use! Import CartProvider and wrap your root component in the CartProvider context:

import { CartProvider } from "alla-cart";
// main.tsx or root component
<CartProvider
  products={sampleProducts}
  getItemPrice={(item) => item.unit_price}
>
  <App />
</CartProvider>;

The context provider takes two props: products and getItemPrice.

  • The first is a data obj of products you'd like to use in the cart. The only data requirement for this is an id property for cart functionality.

  • The second is a callback to pass in a custom price value from the product dataset. This allows the cart to disregard specific price identifiers when computing cart totals. This can be any price identifier used in your product data obj: price, unit_price, amount, etc.

Finally, import the AllaCart component and useCart hook into your app.

import { AllaCart, useCart } from 'alla-cart';

const App = () => {
  const { addToCart } = useCart();

  return (
    <>
    <AllaCart renderCartItem={(item) => {
        return (
          // custom cart data component
          <CartItem id={item.id} image={item.image} name={item.name} description={item.description} price={item.unit_price} />
        )
      }} checkoutComponent={<Checkout />} cartIcon={<BiSolidCart />} currencyLocale={'es-ES'} currencyType={'EUR'}
    />
  )
  ...

  <div>
    {sampleProducts.map((product) => {
        // sample product catalog
        return (
            <div>
              <h2>{product.name}</h2>
              <button className="cart-add" onClick={() => addToCart(product.id)}>add to cart</button>
            </div>
          )
    })}
  </div>
}

Component props

The AllaCart component accepts several props for additional customization.

type CartProps = {
  renderCartItem: (item: any) => React.ReactNode, // product cart data callback - required
  cartLabel?: string, // cart title - optional
  cartCTAButtonText?: string, // cta message - optional
  cartCTAButtonLink?: string, // cta link - optional
  cartCTABackgroundColor?: string, // cta background color - optional
  cartCTAColor?: string, // cta color - optional
  emptyCartText?: string, // custom empty cart message - optional
  cartCTAButtonStyle?: 'regular' | 'pill', // button style - optional
  cartIcon?: React.ReactNode, // custom cart icon - optional
  trashIcon?: React.ReactNode, // custom trash icon - optional
  quantityButtonPadding?: string // custom padding for the quantity counter (+/-) - optional
  quantityCountBackgroundColor?: string // qty counter background color - optional
  quantityCountColor?: string, // qty counter color - optional
  checkoutComponent?: React.ReactNode, // custom checkout component - optional
  currencyLocale?: string | 'en-US', // currency locale - optional
  currencyType?: string | 'USD' // currency - optional
}

The only required prop is renderCartItem, which accepts a callback to a data obj that contains your cart's products.

The easiest way to use this is to simply pass in a custom component containing your product data. The cart will store and retrieve this data from localstorage.

The checkoutComponent prop supports a custom checkout handler.

Additional props support custom text, CTA buttons, and custom icons.

Finally, there is locale / currency support for cart totals. Display your cart totals in multiple currencies for multiple locales. Simply declare the currencyLocale and currencyType props to display cart totals in your desired currency. These default to en-US and USD.

  • Note: The user is responsible for locale and currency support in the product data being supplied to the cart.

Hooks

The useCart hook allows access to the following cart operations:

cartProducts, addToCart, decrementCartItem, incrementCartItem, removeCartItem, clearCart, getCartTotal, getCartItems currencyFormatter

The addToCart hook is used to tell the cart which products will be stored and included in the cart. It accepts one argument of product id.

<button className="cart-add" onClick={() => addToCart(product.id)}>
  add to cart
</button>

The class cart-add should be added to this button to ensure the cart flyout triggers anytime the 'add to cart' event is triggered.