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

snappycart

v1.2.6

Published

A lightweight, embeddable React cart component with context support

Readme

snappycart License npm Build and Test PRs Welcome Conventional Commits

snappycart demo preview

Documentation · npm package · Quick start · Core exports · Contributing

snappycart

snappycart is a headless React cart package for teams that want full control over cart UX without building cart state from scratch.

It gives you the core cart engine, optional UI components, and a clean integration path, so you can move faster without getting locked into a heavy commerce platform.


Where to go next

New to snappycart?

Ready to use it?

Want to work on the repo?


Why snappycart?

Most cart solutions are either too basic or too opinionated.

snappycart gives you the core cart engine and UI building blocks, so you can ship your own cart UX without fighting a framework.

  • Headless by default: bring your own UI, or use the included drawer and cart icon
  • Type-safe: first-class TypeScript types and predictable APIs
  • Composable: works with different React app architectures, from small SPAs to larger storefronts
  • Focused: solves cart state cleanly without dragging in a full commerce platform
  • Built to grow: structured for future extensions without forcing a rewrite

Features

  • cart primitives: addItem, removeItem, increment, decrement, setQuantity, clear
  • React context and hook: CartProvider, useCart
  • optional UI components: CartDrawer, CartIcon
  • flexible product model with support for custom metadata
  • derived cart values like totalItems and subtotal

Core exports

| Export | Type | Purpose | | --- | --- | --- | | CartProvider | Provider | Wraps your app with cart state | | useCart | Hook | Access cart actions and derived state | | CartDrawer | UI component | Optional ready-made cart drawer | | CartIcon | UI component | Optional cart trigger |


Who it is for

| Audience | Why snappycart fits | | --- | --- | | React developers | Add cart functionality without adopting a full commerce platform | | Frontend engineers | Keep full control over UI while reusing solid cart state logic | | Product teams | Ship custom cart flows faster with a lightweight foundation | | Contributors | Improve the package, tests, demo app, or docs in an open repo |


📦 Installation

For package consumers:

npm install snappycart

To use the provided styles:

import "snappycart/styles.css";

Quick Start

1. Wrap your app with CartProvider

import { CartProvider } from "snappycart";

export function App() {
    return (
        <CartProvider>
            <Storefront />
        </CartProvider>
    );
}

2. Add products to the cart with useCart

import { useCart } from "snappycart";

export function AddToCartButton() {
    const { addItem } = useCart();

    return (
        <button
            onClick={() =>
                addItem(
                    {
                        id: "sku_123",
                        name: "Coffee Beans",
                        price: 12.99,
                        imageUrl: "/images/coffee-beans.jpg",
                    },
                    1
                )
            }
        >
            Add to cart
        </button>
    );
}

3. Use the optional cart UI

import { useState } from "react";
import { CartDrawer, CartIcon, useCart } from "snappycart";
import "snappycart/styles.css";

export function Storefront() {
    const [open, setOpen] = useState(false);
    const { totalItems } = useCart();

    return (
        <>
            <CartIcon onClick={() => setOpen(true)} />
            <CartDrawer
                open={open}
                onClose={() => setOpen(false)}
                title={`Your cart (${totalItems})`}
            />
        </>
    );
}

4. Access cart state anywhere

import { useCart } from "snappycart";

export function CartSummary() {
    const { items, subtotal, totalItems, clear } = useCart();

    return (
        <section>
            <p>Total items: {totalItems}</p>
            <p>Subtotal: £{subtotal.toFixed(2)}</p>
            <button onClick={clear}>Clear cart</button>

            <ul>
                {items.map((item) => (
                    <li key={item.product.id}>
                        {item.product.name} × {item.quantity}
                    </li>
                ))}
            </ul>
        </section>
    );
}

Documentation

Explore the docs for setup, usage, and UI customization:

📂 Getting Started ⤴

📂 Theming ⤴

For contribution workflow and repository-specific guidance, see CONTRIBUTING.md.


Repository structure

This repository is a workspace monorepo. Not every folder matters to every contributor.

snappycart repository structure

Folder guide

  • packages/snappycart
    The publishable npm package. This is the main folder for developers working on snappycart itself.

  • apps/demo
    Demo app for testing and showcasing the package in a real UI.

  • apps/documentation
    Documentation site source. Most package users do not need this folder.

  • cypress
    Cypress testing setup and support files.

  • playwright
    Playwright testing setup.

  • .github/workflows
    CI and automation workflows.

snappycart/
├── apps/
│   ├── demo/
│   └── documentation/
├── packages/
│   └── snappycart/
├── cypress/
├── playwright/
├── .github/
│   └── workflows/
├── CONTRIBUTING.md
├── README.md
├── SECURITY.md
└── package.json

Quick orientation

If you are using snappycart in your own app, the main thing you care about is:

packages/snappycart

If you are contributing to docs, go to:

apps/documentation

If you are contributing tests, you will mostly care about:

  • cypress
  • playwright
  • packages/snappycart
  • apps/demo

Contributing

snappycart is developed in the open, and contributions are welcome.

You can contribute through:

  • bug fixes
  • test coverage
  • docs improvements
  • package enhancements
  • demo improvements
  • CI and workflow polish

Start here:

Your first pull request ↗

GitHub Issues ↗

Good first issues ↗

Contributing guide ↗

Security policy ↗

If you cloned the repository locally for development, install dependencies from the root and build the workspaces before working across the repo:

npm install
npm run build

You can then either work from the repo root with workspace commands, or move into a specific workspace and run that folder’s local scripts.


License

snappycart is MIT licensed ↗

snappycart demo preview