0.0.7 • Published 1 year ago

awaitnostr v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago


GitHub license npm npm Github Stars

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)
22
53

Chrome

Elapsed Time (s)Interval Time (s)
22

Brave

Elapsed Time (s)Interval Time (s)
22
53
9.54.5
16.256.75

License

  • MIT
0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago