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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-shopify-drop

v0.1.23

Published

react-shopify-drop is a react library for interacting with [shopify's storefront api](https://shopify.dev/api/storefront#top).

Readme

react-shopify-drop (not production ready)

react-shopify-drop is a react library for interacting with shopify's storefront api.


⚠️ Status: Alpha — please don't use this in production unless willing to contribute to the library.

This is a private package from basement.studio.

Installation

Use the package manager yarn to install react-shopify-drop.

yarn add react-shopify-drop

First steps

Set up

app.js

import {
  createStorefrontClient,
  StorefrontProvider
} from 'react-shopify-drop';

export const storefrontClient = createStorefrontClient({
  accessToken: 'storefront-app-access-token',
  endpoint: 'storefront-app-graphql-endpoint',
});

const App = () => (
  <StorefrontProvider
    appCartId="app-name-cart-id"
    client={storefrontClient}
  >
    <MyApp />
  </StorefrontProvider>
);

export default App;

Usage

component.js

Under the hood, the <StorefrontProvider /> creates a friendly API with a set of useful properties to interact with your shopify application

import { useStorefront } from 'react-shopify-drop';

const Component = () => {
  const api = useStorefront();

  return <div />;
};

API properties

The API comes in form of an object with the following properties:

cart: object

An object which contains the shopify users cart.

cartItemsCount: number

The amount of items in the current cart.

cartToggleState: object

A toggle state to help manage the cart UI state (opened / closed).

  • isOn: boolean - Defines the cart UI state.
  • handleToggle: function - Toggles the cart UI state.
  • handleOn: function - Sets the cart UI state as on (opened).
  • handleOff: function - Sets the cart UI state as on (closed).
errors: object

An object containing a set of possible errors

  • createCartError: Error | null
  • addLineItemError: Error | null
  • updateLineItemError: Error | null
  • removeLineItemError: Error | null
onAddLineItem: function ({ merchandiseId: string, quantity: number }) => Promise<void>

Adds an item to the shopify cart.

onUpdateLineItem: function ({ merchandiseId: string, quantity: number }) => Promise<void>

Updates an item inside the shopify cart.

onRemoveLineItem: function ({ merchandiseId: string }) => Promise<void>

Removes an item from the shopify cart.

Using the full Storefront client

In the other hand, you can also export the created client and import it outside your application frontend (f.e: next.js page getStaticProps function)

import { storefrontClient } from '~/pages/_app.js';

export const getStaticProps = async () => {
  const { product } = await storefrontClient.GetProductByHandle({ handle: 'my-product' });

  return {
    props: {
      product
    },
    revalidate: 1
  };
};

Client properties

CreateCart: function (variables?: CreateCartMutationVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<CreateCartMutation>

Creates a new cart.

CreateCartWithLines: function (variables: CreateCartWithLinesMutationVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<CreateCartWithLinesMutation>

Creates a new cart with line.

AddLineItem: function (variables: AddLineItemMutationVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<AddLineItemMutation>

Adds an item to a line.

UpdateLineItem: function (variables: UpdateLineItemMutationVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<UpdateLineItemMutation>

Updates a line.

RemoveLineItem: function (variables: RemoveLineItemMutationVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<RemoveLineItemMutation>

Removes an item from a line.

FetchCart: function (variables: FetchCartQueryVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<FetchCartQuery>

Fetches an already created cart.

GetProductByHandle: function (variables: GetProductByHandleQueryVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<GetProductByHandleQuery>

Fetches a product based on a handle.

GetAllProducts: function (variables?: GetAllProductsQueryVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<GetAllProductsQuery>

Fetches all products on a shop.

GetProductsOnCollection: function (variables: GetProductsOnCollectionQueryVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<GetProductsOnCollectionQuery>

Fetches all collection products on a shop.

GetCollections: function (variables?: GetCollectionsQueryVariables, requestHeaders?: Dom.RequestInit["headers"]) => Promise<GetCollectionsQuery>

Fetches all collections.

Request: function (query: string, variables?: Record<string, any>) => Promise<any>

Executes a custom query.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT