đ¨âđģđ¨đģ Getting Started
Last updated
Last updated
Browsers with WebLN capabilities provide APIs using a global JavaScript variable window.webln
that can be used to interact with the connected Bitcoin Lightning wallet.
You don't need to add any library to your project.
Before you start using WebLN you need to check for browser support by checking if the variable window.webln
is defined:
window.webln
might not be available during pageload. See the code example below for proper detection.
Before you can work with any of the WebLN APIs you need call the method enable()
:
Depending on the used WebLN provider this will ask the user to connect their Lightning wallet with the website.
You should only initiate a request in response to direct user action, such as clicking a button.
Now you are ready to work with the WebLN APIs.
Have a look at the the WebLN Reference for detailed explanations and usage examples for the different APIs.
WebLN triggers events like webln:enabled
upon enabling, allowing apps and packages to subscribe and listen to these events.
There are different errors that can happen while using the WebLN APIs. Make sure to handle them and let the user know what went wrong.