Skip to content

Latest commit

Β 

History

History
124 lines (94 loc) Β· 7.9 KB

File metadata and controls

124 lines (94 loc) Β· 7.9 KB

LightningConnect

Live demo: lightningconnect.lovable.app

Zero-friction Bitcoin wallet connection for any web app.

LightningConnect is a drop-in React widget + hook that solves wallet connection and automatic payment detection for Bitcoin web apps. Blink-native, universally compatible, and built so developers never write polling logic again.

  • Blink-native β€” two dedicated Blink connectors (Address + API Key)
  • Universally compatible β€” generic Lightning Address + NWC for every other wallet
  • Auto payment detection β€” onPayment callback fires once, automatically
  • Auto cleanup β€” watchers stop on PAID/EXPIRED and on unmount
  • Light & dark mode β€” built-in theme toggle with persisted preference
  • Encrypted local storage β€” device-bound via Web Crypto
  • <30kb gzipped β€” only React as a peer dep
npm install lightningconnect

Quick start

import { LightningConnect, useWalletConnect } from "lightningconnect";

export default function App() {
  const { connect, isConnected, makeInvoice } = useWalletConnect({
    onPayment: (invoice) => alert(`Paid: ${invoice.amount} sats`),
    onExpiry: (invoice) => console.log("Expired", invoice.paymentHash),
  });

  return (
    <>
      <LightningConnect theme={{ primary: "#F7931A" }} />
      {isConnected ? (
        <button onClick={() => makeInvoice(1000, "BTC", "Coffee")}>
          Get paid 1000 sats
        </button>
      ) : (
        <button onClick={connect}>Connect wallet</button>
      )}
    </>
  );
}

No setInterval, no useEffect, no cleanup. LightningConnect starts watching as soon as makeInvoice() resolves and fires onPayment exactly once when it settles.

The four connectors

LightningConnect groups its connectors into two categories β€” Blink (native, premium) and Other Wallets (universal compatibility).

Category Connector Best for
Blink Blink Lightning Address Most users. Just a username, no setup.
Blink Blink API Key Power users. Full account control.
Other β‚Ώ Lightning Address Any user@domain β€” WoS, Alby, Strike, etc.
Other Nostr Wallet Connect (Beta) Alby Hub, Zeus, Phoenix, Mutiny

This repo

This repository contains two things:

  1. /lightningconnect/ β€” the npm package (source, tests, build config)
  2. /src/ β€” the marketing site and live playground at lightningconnect.lovable.app

Package structure

lightningconnect/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ widget.tsx              # <LightningConnect /> modal component
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   └── useWalletConnect.ts # Core hook with payment detection
β”‚   β”œβ”€β”€ connectors/             # Blink Address, Blink API, LNURL, NWC
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   └── paymentWatcher.ts   # Standalone watchPayment utility
β”‚   └── index.ts                # Public exports
β”œβ”€β”€ README.md                   # Full package docs
β”œβ”€β”€ package.json
└── ...

Site structure

src/
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ index.tsx               # Landing page + live playground
β”‚   └── readme.tsx              # Inline README viewer
β”œβ”€β”€ router.tsx
└── ...

Running locally

# Install dependencies
bun install

# Run tests
bun test

# Start dev server (site + playground)
bun run dev

# Build package
bun run build:lib

Documentation

Full API documentation lives in lightningconnect/README.md and covers:

  • useWalletConnect hook API and callbacks
  • watchPayment standalone utility
  • Connector details and setup instructions
  • Theming (dark mode, light mode, custom overrides)
  • Encrypted storage and export/import
  • TypeScript types

License

MIT.