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

@funnelsgrove/sdk

v0.4.0

Published

Embed FunnelsGrove paywalls in web applications

Readme

@funnelsgrove/sdk

Embed a published FunnelsGrove paywall directly in a web app. No app backend, secret key, or paywall session is required. The package has no framework dependency.

npm install @funnelsgrove/sdk

The implementation is a release candidate. npm currently contains the metadata-only 0.0.0-bootstrap.0 reservation, without executable SDK code.

Mount in your frontend

import { mountPaywall } from '@funnelsgrove/sdk';

const paywall = mountPaywall({
  container: '#paywall',
  paywallUrl: 'https://pay.example.com/paywall',
  ...(currentUser.funnelsGroveUserId
    ? { userId: currentUser.funnelsGroveUserId }
    : { email: currentUser.email }),
  returnUrl: '/billing/complete',
  onReady: ({ userId }) => console.log('Paywall ready for FG user', userId),
  onComplete: () => console.log('Payment confirmed'),
  onError: (error) => showPaymentError(error.message),
});

// On route change, modal close, or component cleanup:
paywall.destroy();

paywallUrl is the published paywall route, without query parameters or a fragment. Use HTTPS in production; localhost HTTP is supported for development. The published funnel supplies its public FG key and funnel configuration.

Provide FG userId or email. userId is the existing FG public user_id, scoped to this funnel and Test/Live environment. It is not your application's account ID or FG's internal row ID. Unknown IDs fail without creating a user or falling back to email. With email only, FG normalizes and reuses or creates the canonical user. Concurrent requests for the same email converge on one user. If both fields are provided, they must match or resolution fails. Resolution does not change an existing user's email or purchase history. onReady({ userId }) exposes the selected FG ID; the mount keeps it for subsequent provider returns. If an email form in the paywall resolves another owner, it shows a conflict inside the iframe and keeps the current buyer; reopen from the app to select a different account.

This follows FG's public checkout identity model. Browser-supplied ID/email is not proof of ownership of an authenticated app account. This SDK does not change the access model of existing public user APIs.

Completion and return URL

returnUrl is optional. Relative URLs resolve against the app page. After FG verifies the successful checkout, the SDK calls onComplete once per mount and navigates the parent window to returnUrl. Without it, the caller handles navigation. Pending or failed payments do not redirect. The destination is kept in the parent; child messages cannot replace it. A configured redirect still runs if onComplete throws; use the callback for synchronous notification and handle callback errors in your app.

Use verified billing webhooks/subscription state to grant and revoke access, including renewals and cancellations. Browser callbacks and redirects only tell the app to refresh that state.

onError receives a PaywallError with code:

  • paywall_unavailable: reopen the paywall or correct its configuration/identity.
  • confirmation_pending: keep the iframe and use Check payment status.
  • payment_failed: keep the iframe to let the buyer try again.

The SDK checks message origin, sender window and iframe instance, and adjusts iframe height. Settings are exchanged using postMessage; user identity and the app return URL are absent from iframe/provider URLs. Provider success/failure returns reload the FG paywall and recover settings from the original mounted parent. Keep that parent mounted during redirects. A replaced parent or a provider return into a top-level window requires reopening from the app. Solidgate return recovery also uses sessionStorage for its checkout ID; blocked storage can prevent redirect recovery. Inline checkout does not need that storage.

Payment setup and rollout

The funnel uses its existing Stripe/Solidgate checkout, including eligible wallets. The iframe has allow="payment *". Register/verify both app and funnel domains for Apple Pay, and configure Google Pay with the provider. Hosting frame-ancestors and app frame-src policies must permit the intended origins. Real wallets and 3DS require provider/browser acceptance; local fixtures do not establish that support.

Publish SDK, runtime, analytics and payments in dependency order, deploy the matching API, then rebuild the target funnel. Older funnels do not understand this embed protocol. The API image builds local SDK/runtime tarballs before their npm release, but promotion's CLI gate needs published package artifacts.

This is an ESM package. TypeScript supports moduleResolution: "NodeNext" or "Bundler". There is no server import; @funnelsgrove/sdk/embed is the internal FG runtime bridge. The canonical behavior and test mapping are in docs/product-specs/sdk.md.