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

@snap-pay/react

v1.3.0

Published

React bindings for SNAP Elements - provider, hooks, and component wrappers.

Readme

@snap-pay/react

React bindings for SNAP Elements - provider, hooks, and component wrappers.

pnpm add @snap-pay/js @snap-pay/elements @snap-pay/react

Usage

import { Snap } from "@snap-pay/js";
import "@snap-pay/elements"; // side effect: registers every element
import {
  SnapProvider,
  PaymentElement,
  BillingAddressElement,
  CustomerElement,
  useSnap,
  useElements,
  useClientSecret,
} from "@snap-pay/react";

const snap = new Snap(process.env.NEXT_PUBLIC_SNAP_PK!);

export function CheckoutPage({ clientSecret }: { clientSecret: string }) {
  return (
    <SnapProvider snap={snap} clientSecret={clientSecret}>
      <CustomerElement />
      <BillingAddressElement defaultCountry="Somalia" />
      <PaymentElement />
      <ConfirmButton />
    </SnapProvider>
  );
}

function ConfirmButton() {
  const snap = useSnap();
  const elements = useElements();
  const clientSecret = useClientSecret();
  return (
    <button
      onClick={async () => {
        const result = await snap.confirmPayment({ elements, clientSecret });
        if (result.status === "succeeded") window.location.href = "/thanks";
      }}
    >
      Pay
    </button>
  );
}

Components

Every wrapper accepts the standard event props (onReady, onChange, onFocus, onBlur, onFailed) plus style and className for the outer container.

| Component | Notes | |---|---| | <PaymentElement /> | Umbrella - auto-picks Wallet + Card | | <WalletElement /> | Mobile-wallet radio buttons | | <CardElement /> | Card fields inside a cross-origin iframe. Sandbox only (see below) | | <ExpressCheckoutElement /> | Prominent one-tap buttons; adds onSubmit for the click event | | <PaymentMethodSelector /> | Tabbed Wallet/Card switcher | | <BillingAddressElement defaultCountry={...} /> | Address form | | <CustomerElement /> | Name / email / phone | | <QrElement /> | QR code for the hosted checkout URL; onChange fires with complete: true when paid, onFailed on cancel or expiry |

Also exported: <QrCode /> (standalone QR image), <ThreeDsChallenge /> (3-D Secure challenge iframe) and <MastercardCardElement />, which is fail-closed: it renders a notice and calls onError instead of card inputs.

Live card payments

Live card tokenization in Elements is not available yet. <CardElement /> issues sandbox tokens only, and confirmPayment throws for a card selection under a pk_live_ key. For live card payments, redirect the customer to SNAP-hosted checkout (the checkout session URL). Wallet Elements work in live mode.

Next.js

The package ships a "use client" directive, so it can be imported from App Router server components; the components themselves render on the client.

Hooks

  • useSnap() - the Snap instance from the provider
  • useElements() - the shared Elements handle
  • useClientSecret() - the client secret

All three throw if called outside a <SnapProvider>.

License

MIT