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

@ledewire/browser

v0.7.0

Published

LedeWire SDK for browsers — embed a paywall with a single script tag

Downloads

1,087

Readme

@ledewire/browser

npm License: MIT

Browser SDK for the LedeWire content marketplace — embed buyer authentication, wallet funding, content purchases, and seller content discovery on any website with a single script tag.

CDN — No Install Required

<!-- Pin to a major version in production -->
<script src="https://cdn.jsdelivr.net/npm/@ledewire/browser@0/dist/ledewire.min.js"></script>
<script>
  const lw = Ledewire.init({ apiKey: 'your_api_key' })

  // Determine what the visitor needs to do next
  const state = await lw.checkout.state('content-id')
  // state.checkout_state.next_required_action:
  //   'authenticate' | 'fund_wallet' | 'purchase' | 'view_content'
</script>

npm / ESM

npm install @ledewire/browser
import { init, localStorageAdapter } from '@ledewire/browser'

const lw = init({
  apiKey: 'your_api_key',
  // Persist sessions across page reloads (defaults to in-memory)
  storage: localStorageAdapter(),
  // Called when the session expires and cannot be refreshed
  onAuthExpired: () => showLoginModal(),
})

Client Namespaces

| Namespace | Description | | ------------------- | ------------------------------------------------------------------------------- | | lw.config | Platform public config (no auth required) | | lw.auth | Buyer signup, email/password login, Google OAuth, API key login, password reset | | lw.wallet | Wallet balance, fund wallet via payment session | | lw.purchases | List and create content purchases | | lw.content | Fetch content with buyer access info | | lw.checkout | Checkout state — what action is required next | | lw.seller.content | List, search, and get store content (API key auth) |

Example: Fetch Google OAuth Client ID Before Sign-In

const lw = Ledewire.init({ apiKey: 'your_api_key' })

// No login needed — safe to call on page load
const { google_client_id } = await lw.config.getPublic()
google.accounts.id.initialize({ client_id: google_client_id, callback: handleCredential })
google.accounts.id.renderButton(document.getElementById('signin-btn'), { theme: 'outline' })

Example: Full Checkout Flow

const lw = Ledewire.init({ apiKey: 'your_api_key' })

const { checkout_state } = await lw.checkout.state('article-123')

switch (checkout_state.next_required_action) {
  case 'authenticate':
    await lw.auth.loginWithEmail({ email, password })
    break
  case 'fund_wallet':
    const session = await lw.wallet.createPaymentSession({ amount_cents: 500 })
    // redirect to session.payment_url
    break
  case 'purchase':
    await lw.purchases.create({ content_id: 'article-123' })
    break
  case 'view_content':
    const { content_type, content_body, content_uri } =
      await lw.content.getWithAccess('article-123')
    if (content_type === 'markdown') {
      // content_body is plain text — the SDK decodes base64 automatically
      renderMarkdown(content_body)
    } else {
      // redirect to the gated external URI (Vimeo, PDF, etc.)
      window.location.href = content_uri
    }
    break
}

Example: Seller Content Discovery

Use lw.seller.loginWithApiKey with only the key to obtain a read-only token, then browse your store's content catalogue directly from the browser:

const lw = Ledewire.init({ apiKey: 'your_api_key' })

// Obtain a view-only seller token (key only — no secret needed)
await lw.seller.loginWithApiKey({ key: 'your_api_key' })

// List all content
const items = await lw.seller.content.list()

// Search by title, URI, or metadata
const results = await lw.seller.content.search({ title: 'intro' })
const byMeta = await lw.seller.content.search({ metadata: { author: 'Alice' } })

// Fetch a single item
const item = await lw.seller.content.get('content-id')

Token Storage

By default tokens are stored in memory (most secure — cleared on page unload). Two built-in adapters are available for persistent sessions:

import { init, localStorageAdapter, sessionStorageAdapter } from '@ledewire/browser'

// Persists across tabs and browser restarts
const lw = init({ apiKey: '...', storage: localStorageAdapter() })

// Persists within the current tab only (cleared on tab close)
const lw = init({ apiKey: '...', storage: sessionStorageAdapter() })

Token refresh is handled automatically — you never need to call a refresh method manually.

Documentation

License

MIT