Lightning Network Client (LN) Documentation
May 12, 2026 ยท View on GitHub
The LN class helps you easily get started interacting with the lightning network. It is a high level wrapper around the NWCClient which is compatible with many different lightning wallets.
See LNClient class documentation
For example, to make a payment:
import { LN, USD, SATS } from "@getalby/sdk/lnclient";
const credentials = "nostr+walletconnect://..."; // the NWC connection credentials
await new LN(credentials).pay("lnbc..."); // pay a lightning invoice
await new LN(credentials).pay("hello@getalby.com", SATS(21)); // or pay 21 sats to a lightning address
await new LN(credentials).pay("hello@getalby.com", USD(1)); // or pay \$1 USD to a lightning address
await new LN(credentials).pay("hello@getalby.com", new FiatAmount(1, "THB")); // or pay an amount in any currency to a lightning address
await new LN(credentials).pay("hello@getalby.com", USD(1), {
metadata: { comment: "Example comment", payer_data: { name: "Bob" } },
}); // set a comment for the payment you are making, and that the payment was made by Bob
Or to request to receive a payment:
const request = await new LN(credentials).requestPayment(USD(1.0));
// give request.invoice to someone, then act upon it:
request
.onPaid(giveAccess) // listen for incoming payment and then fire the given method
.onTimeout(60, showTimeout); // if they didn't pay within 60 seconds, do something else
Examples
See the LNClient examples directory for a full list of examples.
For Node.js
Node.js 22 or higher is required (for native WebSocket support). On older versions you can install websocket-polyfill@0.0.3 and import it before using the SDK (not recommended).