Package Exports
- awaitnostr
- awaitnostr/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (awaitnostr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
awaitnostr
Documentation
Introduction
awaitnostr
is a utility function that allows you to wait for window.nostr
to be defined before using window.nostr
functions. This can be useful when using the Nostr browser extension API in your web app, as window.nostr
may not be defined immediately upon page load.
Import from CDN
To import the awaitnostr
module from a CDN, add the following line to your HTML file:
import awaitNostr from 'https://cdn.skypack.dev/awaitnostr'
Usage
To use awaitnostr
, simply import the awaitNostr()
function from the package:
import awaitNostr from 'awaitnostr'
Then call the awaitNostr()
function before using any window.nostr
functions:
async function myFunction() {
await awaitNostr();
const publicKey = await window.nostr.getPublicKey();
// Do something with publicKey
}
Demo
You can view the demo by clicking here.
Browser Performance Benchmarks
Below are the performance benchmarks for different web browsers:
Firefox
Elapsed Time (s) | Interval Time (s) |
---|---|
2 | 2 |
5 | 3 |
Chrome
Elapsed Time (s) | Interval Time (s) |
---|---|
2 | 2 |
Brave
Elapsed Time (s) | Interval Time (s) |
---|---|
2 | 2 |
5 | 3 |
9.5 | 4.5 |
16.25 | 6.75 |
License
- MIT