WebLN
v0.3.2
WebLN
v0.3.2
Overview
IntroductionGetting StartedUX Best Practices
GitHub
Edit this page on GitHub
Edit

Getting Started

To start using WebLN, you'll need access to the client library. You can either install the package, or include a script. It's highly recommended that you install the package and bundle it rather than relying on an external script.

Installation

Install with Package Manager (Preferred)

Install the webln library using your package manager of choice:

  • npm: npm install --save webln
  • yarn: yarn add webln

And import it in your project wherever you need it:

import { requestProvider } from "webln";

Include Script (Alternative)

Alternatively you can include a script in your page that will load the library. Be sure to keep the integrity check to prevent malicious Javascript from loading.

<script
  src="https://unpkg.com/[email protected]/dist/webln.min.js"
  integrity="sha384-MpjpvOQqXz9nCoLUS/sR0bhLwGYuNPMOBN50jsqhnqAzDq0GiOI0u6oC5fHitzI2"
  crossorigin="anonymous"
></script>

This will provide a global WebLN object in your code, so anywhere you see an import statement, you can ignore that and access the same code from the global WebLN object. For instance, the following code:

import { requestProvider } from "webln";
requestProvider(/* ... */);

would instead look like this:

WebLN.requestProvider(/* ... */);

Available libraries for a quick start

  • Pay with LN - WebLN enabled payment button
  • React WebLN Fallback - React components and standalone library for handling WebLN calls without WebLN

You're All Set

From here, check out how to use requestProvider and the provider API methods. Make sure you take a look at the source code for each method's demo to fully understand it.