WebLN
v0.3.2
WebLN
v0.3.2
Overview
IntroductionGetting StartedUX Best Practices
Client API Reference
requestProviderwebln.getInfowebln.sendPaymentwebln.makeInvoicewebln.signMessagewebln.verifyMessageErrors
GitHub
Edit this page on GitHub
Edit

requestProvider

To begin interacting with a user's Lightning node, you'll first need to request a WebLNProvider from them. WebLNProvider is a class that various clients implement and attach to your web session. Calling requestProvider will retrieve the provider for you, and prompt the client for permission to use it. Once you get the provider, you're free to call all of the other API methods.

Note that this is an asynchronous operation, and the client can reject access to the provider even if it's available. The request will also fail if there's no provider available.

Example

import { requestProvider } from "webln";

try {
  const webln = await requestProvider();
  // Now you can call all of the webln.* methods
} catch (err) {
  // Tell the user what went wrong
  alert(err.message);
}