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

@whop/elements-react-native

v0.7.0

Published

Whop Elements — native React Native components for collecting payments.

Readme

@whop/elements-react-native

Native React Native components for collecting payments with Whop.

The elements are real React Native views, and card fields are PCI-isolated by Basis Theory's React Native SDK. The pieces only the platform can do, the Apple Pay and Google Pay sheets, their branded buttons, and the system browser a 3DS step opens in, are Swift and Kotlin behind React Native Codegen.

import {
  WhopElements, Payments, PaymentElement, AddressElement, EmailElement, BrandingElement,
} from '@whop/elements-react-native';

<WhopElements environment="production">
  <Payments ref={payments} accountId="biz_…" plan="plan_…">
    <EmailElement />
    <AddressElement />
    <PaymentElement onChange={(e) => setReady(e.complete)} />
    <BrandingElement />
  </Payments>
</WhopElements>;

const { confirmationToken } = await payments.current.createConfirmationToken();

Confirm the token server-side, then hand any pending step to payments.current.handleNextAction({ clientSecret }). If the API asks the buyer to prove they are human first, the SDK runs that itself; see Verification challenges.

Requirements

| | | | --- | --- | | React Native | >= 0.87 on Swift Package Manager, >= 0.86 on CocoaPods. New Architecture on | | iOS | 15.1+ | | Android | minSdk 24, compileSdk 37 | | Peers | react and react-native only — no native peer dependencies | | Native dependencies | nSure 1.4.1 and Fingerprint 4.x, resolved by this package's own manifests on both platforms (see Device intelligence) |

The package ships two iOS manifests and the toolchain picks one. React Native's SPM autolinker prefers ios/Package.swift and only falls back to a podspec, so an app on Swift Package Manager is unaffected by the podspec's existence. package.json declares the package's SwiftPM name, ElementsReactNative, in swiftpmConfig: React Native 0.88 links a library by that name and otherwise takes it from the podspec, which would ask for a product this package does not have. The floor is higher there because Package.swift links ReactNativeHeaders and ReactNativeDependenciesHeaders, two header-only XCFrameworks that first shipped in React Native 0.87.

elements-react-native.podspec exists because every CocoaPods-based toolchain discovers native modules by scanning a package for a podspec, and skips a package without one silently rather than failing. That includes Expo, whose iOS autolinking is CocoaPods-based at every released SDK. Without the podspec an Expo app installs this package, builds cleanly, and gets no native module at all.

Elements

| Component | What it collects | | --- | --- | | <PaymentElement /> | The offered payment methods and the selected one's required fields | | <AddressElement /> | A postal address, in the selected country's own format | | <CardElement /> | Card number, expiry, and security code, prearranged | | <CardFields> + <CardNumberElement /> <CardExpiryElement /> <CardCvcElement /> | The same three fields, placed individually | | <EmailElement /> | The buyer's email | | <TaxIdElement /> | A business tax registration | | <BrandingElement /> | Whop's merchant-of-record notice | | <ExpressCheckoutElement /> | One Apple Pay or Google Pay press that pays a whole checkout, under <Checkout> |

<BrandingElement /> is required beside a payment surface: Whop is the merchant of record on these sales, so createConfirmationToken refuses with BRANDING_NOT_MOUNTED without it.

<AddressElement /> autocompletes by default from the platform geocoder, MKLocalSearchCompleter on iOS and android.location.Geocoder on Android, so it needs no API key, no account, no location permission and no extra dependency. Android resolves a complete address rather than predicting from a fragment, so expect fewer and coarser suggestions there. A geocoder with no matches shows nothing and the buyer types the address by hand, which is where they started: autocomplete never blocks a checkout. Pass autocomplete={false} to turn it off.

<Payments>

| Prop | | | --- | --- | | accountId | The Whop company the sale belongs to | | plan | The plan being sold, which resolves the currency, amount and offered methods. Pass currency and amount instead for an ad-hoc charge | | mode | payment (default) charges; setup saves a payment method without charging: pass currency, never plan or amount; methods that cannot be saved are not offered and amount limits do not apply; confirm as usual and create the setup intent from your server | | returnUrl | Where the issuer returns after a redirect or 3DS step. Must be https and hosted by you, because the API refuses anything else, so a custom app scheme will not work. You do not register a deep link: handleNextAction polls the payment to rest and closes the browser itself. A setup's sint_… secret is handled the same way against the setup intent | | googlePayMerchantName | The name shown in the Google Pay sheet, defaulting to Whop. Neither wallet needs anything else from you: Apple Pay uses the merchant registered on the Whop account | | order | The method tile order, with Stripe's paymentMethodOrder semantics |

<Checkout> and <ExpressCheckoutElement />

<WhopElements environment="production">
  <Checkout plan="plan_…" onComplete={({ sessionId, receiptId }) => navigation.navigate('Thanks')}>
    <ExpressCheckoutElement />
  </Checkout>
</WhopElements>

<Checkout> opens a Whop checkout session when it mounts and keeps the session's credential to itself. <ExpressCheckoutElement /> renders the device's wallet button: Apple Pay on iOS, Google Pay on Android. One press is the whole purchase. The sheet collects what the session still needs (the email, a phone number, a shipping address), the element confirms the session, runs any 3DS step in the system browser, and shows a native code step for sellers who verify phone numbers. There is no confirmation token to send to your server. If the API asks for a verification challenge after the buyer authorizes, the sheet closes with success and the challenge runs in the SDK's web view (see Verification challenges).

| Prop | | | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | plan, items, checkoutConfiguration, quantity | What is being bought, with the web element's rules: items is the whole cart, plan beside checkoutConfiguration only sets quantity | | promoCode, affiliateCode, attribution, metadata | Recorded on the session. A promo code that cannot apply opens the checkout at full price | | returnUrl | Where an off-site payment step returns. https, hosted by you, as on <Payments> | | onComplete | ({ sessionId, receiptId }), once, when the purchase stands. Your app is never navigated, so this is where you move the buyer on. Fulfill from webhooks | | onError, onLoadingChange, fallback, style | As on <Payments> |

Every option is create-time. Changing one after mount reports CHECKOUT_OPTIONS_FROZEN and keeps the original order: give <Checkout> a new key to sell something else.

The element renders nothing where the device has no wallet, the checkout's payment method configuration disables it, or the plan cannot be bought right now. A checkout a sheet cannot finish (a setup, a waitlist join, a transfer, a question only a form can ask) shows an explanatory face and reports EXPRESS_CHECKOUT_UNAVAILABLE. On iOS the sheet reprices as the buyer changes card and offers a promo code field when the seller allows codes. Google's sheet has neither on Android. wallets filters what may render, and there is no layout prop because a device only ever offers one wallet.

To open the sheet from your own control, pass button={false} and call present() on the element's ref. The element stays mounted: it still shows its error lines, the phone code step and the branding notice, which must stay on screen beside your control. Show the control only while onAvailabilityChange reports true. present() resolves false without opening anything when the wallet is unavailable or a payment is already running, and true once the attempt settles; the outcome still arrives through onComplete and the element's error lines. Apple's guidelines expect an Apple Pay purchase to start from an Apple Pay button, so check them before shipping a control of your own.

const express = useRef<ExpressCheckoutHandle>(null);
const [available, setAvailable] = useState(false);

<Checkout plan="plan_…" onComplete={onComplete}>
  {available ? <SlideToPay onComplete={() => express.current?.present()} /> : null}
  <ExpressCheckoutElement ref={express} button={false} onAvailabilityChange={setAvailable} />
</Checkout>

Verification challenges

When Whop's API suspects automation on a confirmation-token mint, it answers 422 challenge_required instead of a token. Under <Payments>, the SDK handles that inside its transport: it loads Whop's hosted verification page in an invisible, transparent web view above your app's windows and replays the original request with the proof the page hands back. On Android it gets a window of its own, shown after yours, so it also sits above a React Native <Modal> holding the form. Most buyers never see anything: the page runs the vendor's check silently, and only when a vendor needs the buyer does that same, already running web view slide up in a native bottom sheet at half height (iOS's medium detent), growing to fit a taller check such as an image puzzle (up to full height; iOS 15 stays at half and scrolls), with the platform's grabber and a round close button in its top-left corner (the system glass button on iOS 26, a material one before it, a translucent one on Android), following the device's light or dark appearance. The SDK draws that chrome itself and tells the page to draw none (chrome=none in the page link's fragment), so the page shows only the verification box. createConfirmationToken resolves with the token as if nothing had happened, no element renders a widget, no call site changes, and there is nothing to configure: no URL scheme, no intent-filter, no Linking handling.

The web view is WKWebView on iOS and android.webkit.WebView on Android, created by the SDK's own native module (WhopChallenge); there is no third-party web view package. It only ever loads the hosted page on cdn.whop.com (/hosted-assets/pages/<sha256 hex>.html), checked in JS and again by the native module: an offer naming any other host or path is refused before anything loads, as a challenge that ended without a proof (below), the same answer Elements web gives. Top-level navigation is held to that origin, the vendors' own frames are allowed, and a link the buyer taps opens in the external browser. The page reports its outcome over a JS bridge that accepts messages only from the page's main frame at that origin; each ceremony loads a fresh web view, so what that page posts is that ceremony's own. The page reports ready once it has read its link; one that has not within ten seconds of the load is torn down as unavailable, again a challenge that ended without a proof. Until the page asks for the buyer, the web view is invisible, lets every touch through to your app, and is hidden from assistive technology; once shown, the sheet's close button, a swipe down from its top edge and, on Android, the system back gesture close it. A tap on your dimmed app behind it does nothing, and a drag that starts on the page stays with the page. A solved or failed challenge, the offer's expiry and a <Payments> unmount slide it away. It uses the platform's default, persistent web storage, as Cloudflare requires: a buyer a vendor already trusts passes silently, and only one the page cannot clear is shown a puzzle. A 3DS step is different and stays in the system browser, because that page is the card issuer's, not Whop's.

While developing against a local or devbox Whop backend that serves its own hosted assets (the hosted page among them), pass that origin as devHostedAssetsOrigin on <WhopElements> (for example http://localhost:3000, or https://b<id>.box.whop.dev:13000 on a devbox). The SDK then also trusts that origin, at the same /hosted-assets/pages/<sha256 hex>.html path, alongside cdn.whop.com: https on any host, http only on localhost or 127.0.0.1. It is honored only in a __DEV__ bundle (a release bundle ignores it and logs a warning) and only by a debug native build (iOS compiled with DEBUG, Android when the app is debuggable), so it cannot widen the pin in a shipped app. For the offer to name that page it has to come from the same backend, so pass that backend's origin as devApiBase too (usually the same value, http://localhost:3000 or https://b<id>.box.whop.dev:13000): every request then goes there instead of environment's origin, under the same rules (a bare origin, https on any host, http only on localhost or 127.0.0.1, ignored with a warning outside a __DEV__ bundle).

Both wallet surfaces, the wallet button inside <PaymentElement /> and <ExpressCheckoutElement />, complete the Apple Pay or Google Pay sheet with success the moment the buyer authorizes. Vaulting the wallet's token, minting the confirmation token and confirming all run after the sheet has closed, so a challenge on any of them presents over your app like any other call, and a failure there shows in your UI (the payment element's error line, or the express element's line under its button), not in the sheet. createConfirmationToken refuses with WALLET_UNAVAILABLE until the sheet has handed back its payment.

A solved challenge replays the request with Whop-Challenge: <provider> <challenge token> <vendor token>. If the replay is challenged again, the SDK runs the page once more on the new offer and replays with that fresh proof, at most three pages for one call; a proof is never reused. A fourth challenge_required is handed back as the ordinary API error it is (a WhopError with status 422 and code challenge_required, exactly what a client with no ceremony sees), so a proof the API keeps refusing cannot hold the buyer in a loop. A page that never reports is covered by the offer's expiry: the SDK tears the web view down then, shown or not. It times that from the offer's expires_in when the API sends one, counted from when the offer arrived, so a wrong device clock cannot shorten it; otherwise from expires_at, and never less than 30 seconds. A proof that arrives at the same moment still counts.

A challenge that ends without a proof answers the call with the API's refusal exactly as the SDK received it: the WhopError with status 422 and code challenge_required for the offer that was presented (for a re-offer, that re-offer's), the same error a client with no ceremony sees. There is no challenge-specific error type to handle. That covers a challenge the buyer closed (the sheet's close button, a swipe down from its top edge, or the Android back gesture), one whose page could not load, never reported ready or could not complete it, one whose page was not the hosted page on cdn.whop.com, one that expired, and one that cannot run here: the offer carried no hosted page, the hosted page could render none of the offered challenges, or the device cannot host the web view (the app binary predates the WhopChallenge module, as after an over-the-air JS update, or Android's system WebView is too old for its bridge).

createConfirmationToken wraps that 422 the way it wraps every failed mint: it rejects with a PaymentTokenizationError (code confirmation_token_create_failed) whose buyerMessage is the API's message and whose cause is the WhopError.

The SMS code step for sellers who verify phone numbers presents a challenge the same way. A challenge on the express element's mint, its confirm or the phone step that does not pass fails that step like any refused request: the element shows its usual line under the button, or the phone step its usual error, and the buyer can press again. That line is kept with the checkout, not the element, so an element that remounts while a press is still running shows how that press ended.

Every request also carries Whop-SDK: elements-react-native/<version> (ios|android), so the API knows which client it is assessing. It is a dimension, not a credential.

Releases before 0.5.0 cannot complete a challenge, and nothing they reject with names one: createConfirmationToken wraps every failed mint the same way, so a challenged buyer surfaces as a PaymentTokenizationError with code confirmation_token_create_failed whose buyerMessage is the API's own text. The WhopError carrying the 422 never leaves the SDK, so those releases have no coded way to tell a challenge from any other refused mint.

Device intelligence

<Payments> and <Checkout> start nSure's native SDK on the device once a seller is known (the accountId, or the checkout session's seller) and send its device id as x-nsure-device-id on every API request, the header the web elements send. Whop's API keeps it with the confirmation token and forwards it to nSure when it assesses the payment. Nothing renders and there is nothing to configure.

  • The nSure app id is Whop's and public: one for production, one for sandbox.
  • The partner id nSure sees is the account id itself (biz_…), the same value Whop's API sends with the payment. nSure's SDK is a process-wide singleton that keeps the app id and partner id of its first start, so the SDK starts it once per app launch: an app that shows several sellers or both environments reports the first one, and an app that initializes nSure itself keeps its own.
  • The confirmation-token mint and the checkout confirm, the requests Whop keeps the id from, wait at most one second for a start still in flight; every other request sends the id when it is there and never waits. A start that fails or answers no id is tried again for the next seller, including one that arrived while it was running, and a binary that predates the WhopNsure module sends no header. None of it blocks the buyer.
  • nSure's SDK runs inside the app: it fetches its remote configuration, fingerprints the device through Fingerprint, and installs its crash reporter and lifecycle observers when that configuration turns them on. A debug build on iOS logs it at verbose level to the console.
  • iOS: Swift Package Manager resolves nsure-ai/ios-sdk 1.4.1 and, through it, Fingerprint 4.x; CocoaPods resolves the nSure and Fingerprint-iOS pods. Both are dynamic xcframeworks the app embeds. Fingerprint ships a privacy manifest and links CoreLocation; nSure ships no manifest, so review your app's required-reason API declarations when App Store Connect asks for them.
  • Android: the package resolves com.github.nsure-ai:android-sdk 1.4.1 from JitPack and com.fingerprint.android:sdk 4.0.0 from maven.fpregistry.io, and adds both repositories, scoped to those groups, to every project, unless the build sets React Native's exclusiveEnterpriseRepository property to resolve everything from one mirror. An app that declares its repositories in settings.gradle (dependencyResolutionManagement) adds them there itself. The SDKs' manifests merge DETECT_SCREEN_CAPTURE, INTERNET, ACCESS_NETWORK_STATE and READ_GSERVICES, and Fingerprint adds native libraries for every ABI.

Appearance

One object, applied live — mounted elements restyle in place.

<WhopElements
  appearance={{
    theme: { appearance: 'dark', accentColor: 'blue' },
    tokens: { radius: 12 },
    parts: { 'whop-CardNumberField': { borderWidth: 2 } },
  }}
>

theme is identical to the web elements'. The two deltas are deliberate, because React Native has no CSS:

  • tokens replaces variables — a closed, typed map of numbers, not "8px" strings.
  • parts replaces classes — the same whop-* part names, with React Native style objects instead of CSS declarations. Flat per-part overrides: no cascade, no pseudo-classes.

Passing variables or classes throws by name rather than being silently ignored.

An unset theme.appearance follows the device's colour scheme.

Example app

cd example
pnpm install
pnpm run setup     # generates ios/ and android/, converts iOS to SwiftPM
pnpm run ios       # or: pnpm run android

Set your accountId and plan in example/src/config.ts first. It runs against production by default — switch environment to sandbox there to point at the sandbox API.

ios/ and android/ are generated by pnpm run setup from the official React Native app template rather than committed: they are several hundred files that belong to a React Native version, and regenerating is how the example follows a version bump instead of drifting from it. The example runs React Native 0.88, whose template adopts the UIScene life cycle that an app built with the iOS 27 SDK must have to launch. After a React Native bump, delete the example's Xcode DerivedData (~/Library/Developer/Xcode/DerivedData/WhopElementsExample-*) before building: Xcode keeps precompiled modules built from the previous version's React headers and refuses to rebuild them when the autolinking phase regenerates the header tree mid-build. The script also converts the project to Swift Package Manager without ever invoking pod — it strips CocoaPods out of the .pbxproj directly, because react-native spm add --deintegrate shells out to it.

One deliberate leftover: ios/Podfile stays as a pod-free stub. The React Native CLI locates the iOS project by finding a Podfile, and react-native spm reads that location, so deleting it makes project.ios resolve to null and the SPM setup fail. The example has four screens: a realistic Checkout, Express (a real one-press purchase), a Gallery of each element with live prop controls, and Theming applied to a live form.

The example is its own pnpm install root. React Native's settings.gradle does includeBuild("../node_modules/@react-native/gradle-plugin"), which pnpm's isolated linker does not expose, so example/.npmrc sets node-linker=hoisted — scoped there so the rest of the monorepo stays isolated.

Native layer

Six units, all generated from src/specs/ by React Native Codegen:

| Unit | Kind | iOS | Android | | --- | --- | --- | --- | | WhopAuthSession | Turbo Module | ASWebAuthenticationSession | Chrome Custom Tabs | | WhopChallenge | Turbo Module | WKWebView | android.webkit.WebView + androidx.webkit | | WhopPlatformPay | Turbo Module | PKPaymentAuthorizationController | PaymentsClient | | WhopPayButton | Fabric Component | PKPaymentButton | PayButton | | WhopAddressSuggestions | Turbo Module | MKLocalSearchCompleter | android.location.Geocoder | | WhopNsure | Turbo Module | nSure.xcframework 1.4.1 | com.github.nsure-ai:android-sdk 1.4.1 |

A redirect or 3DS step opens in the system browser, out of process — not a WebView the app can read or script. handleNextAction then polls the payment to rest, because the API accepts only https or loopback return URLs and a custom-scheme deep link back into the app is refused. The one page that does run in an in-app web view is the verification challenge's, because it is Whop's own page on cdn.whop.com: WhopChallenge hosts it transparently in its own window above the app's, on both platforms, invisible until the page reports that the buyer is needed, then shows it in a bottom sheet in that window (a UISheetPresentationController opening at the medium height and sized to the height the page reports on iOS; on Android a sheet drawn from plain views, since the SDK does not depend on Material), and reads the outcome over a bridge (window.webkit.messageHandlers.whopChallenge on iOS, window.whopChallenge from WebViewCompat.addWebMessageListener on Android) from the page's main frame at its origin only.

React Native cannot express a Fabric component or a Turbo Module in pure Swift: both need an Objective-C++ class the C++ renderer can see. Nobody writes it here. scripts/codegen-shims.mjs emits it from the same specs Codegen reads, into the gitignored ios/generated/, during prepare. Every line a human writes on iOS is Swift and on Android is Kotlin.

The SDK has no native peer dependencies, deliberately: under Swift Package Manager, one peer that ships no Package.swift makes the whole app unbuildable, and most of the React Native ecosystem does not ship one yet. That is why the branding wordmark is drawn with plain views rather than react-native-svg. nSure is a dependency of this package's own manifests, not a peer: Package.swift, the podspec and build.gradle each name it, so nothing is installed by hand.

Not in this release

Absent entirely rather than half-present, so nothing renders that cannot work: saved payment methods, the email code sign-in, installment tiers, ledger-balance payment, and the post-confirm instruction panes.

Development

pnpm install
pnpm build          # emits ios/generated, then module + typescript targets
pnpm test
pnpm check-types
pnpm theme          # regenerate src/theme/scales.generated.ts from frosted-ui's stylesheet
pnpm mirror         # which files here mirror the web elements changed on this branch
pnpm check-swift    # typecheck the Swift against the iOS SDK, no app build; downloads the nSure and Fingerprint xcframeworks into ios/.build once
pnpm test-swift     # run the Foundation-only Swift units (the challenge bridge gate) on the host toolchain

Nothing in ios/Sources imports React, so the whole Swift implementation typechecks standalone — a wrong PassKit or AuthenticationServices symbol surfaces in seconds rather than one at a time inside an Xcode build.

pnpm mirror answers the question a web author cannot otherwise ask, which files here implement the same behaviour as the web elements they just changed. scripts/mirror.mjs derives the ported files from their own headers and keeps an explicit table for the element components; pnpm mirror:validate fails if either side of a pair has moved. Add a row when you add an element.

src/core/ is ported from frontend/apps/web/src/elements/. A header states a deliberate difference where one was made on purpose (payments/errors.ts and payments/mint.ts keep the failed call as the mint error's cause), but some headers lag their web source, and pnpm mirror:validate checks only that both sides of a pair exist, not that they match. Each file names its source in a header, and the address engine's own test suite is ported with it, so the port is proved against the same assertions the web elements pass.

CI and npm releases

.github/workflows/frontend-elements-react-native.yml runs the unit tests, typecheck, lint, mirror validation, native shim generation, and package build. It packs the SDK and checks that the JavaScript, declarations, native sources, generated shims, and autolinking config ship. These checks do not build or run an iOS or Android app; native changes still need device verification.

To release, bump this package's version in a PR, add its entry to CHANGELOG.md, and merge it into main. After the checks pass, the workflow publishes the verified tarball. Stable versions go to latest; prereleases use alpha, beta, canary, or rc (for example, 0.2.0-beta.1 goes to beta). Already published versions skip publishing, and older unpublished versions cannot move a channel backwards. The version is not bumped automatically. Merging CI setup with the existing 0.1.0 version therefore does not publish another release.

Publishing uses npm OIDC, following the web Elements workflow. Configure the trusted publisher in the npm settings for @whop/elements-react-native:

  • Provider: GitHub Actions
  • Organization: whopio
  • Repository: whop-monorepo
  • Workflow filename: frontend-elements-react-native.yml
  • Environment: leave blank

No npm token is needed. The publish step runs from the downloaded artifact directory outside frontend so the workspace's install-time npm configuration cannot override OIDC authentication. Provenance is not requested because the source repository is private. If publishing fails, rerun the failed job, or dispatch the workflow on main to retry after checks. Dispatching it on another branch only runs checks.