mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
update readme to mention fragment importing and nostr-wasm.
This commit is contained in:
32
README.md
32
README.md
@@ -202,6 +202,35 @@ assert(data.pubkey === pk)
|
|||||||
assert(data.relays.length === 2)
|
assert(data.relays.length === 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Import modes
|
||||||
|
|
||||||
|
### Using just the packages you want
|
||||||
|
|
||||||
|
Importing the entirety of `nostr-tools` may bloat your build, so you should probably import individual packages instead:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { generateSecretKey, finalizeEvent, verifyEvent } from 'nostr-tools/pure'
|
||||||
|
import { matchFilter } from 'nostr-tools/filter'
|
||||||
|
import { decode, nprofileEncode, neventEncode, npubEncode } from 'nostr-tools/nip19'
|
||||||
|
// and so on and so forth
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using it with `nostr-wasm`
|
||||||
|
|
||||||
|
[`nostr-wasm`](https://github.com/fiatjaf/nostr-wasm) is a thin wrapper over [libsecp256k1](https://github.com/bitcoin-core/secp256k1) compiled to WASM just for hashing, signing and verifying Nostr events.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { setNostrWasm, generateSecretKey, finalizeEvent, verifyEvent } from 'nostr-tools/wasm'
|
||||||
|
import { initNostrWasm } from 'nostr-wasm'
|
||||||
|
|
||||||
|
initNostrWasm().then(setNostrWasm)
|
||||||
|
|
||||||
|
// or use 'nostr-wasm/gzipped' or even 'nostr-wasm/headless',
|
||||||
|
// see https://www.npmjs.com/package/nostr-wasm for options
|
||||||
|
```
|
||||||
|
|
||||||
|
This may be faster than the pure-JS [noble libraries](https://paulmillr.com/noble/) used by default and in `nostr-tools/pure`.
|
||||||
|
|
||||||
### Using from the browser (if you don't want to use a bundler)
|
### Using from the browser (if you don't want to use a bundler)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
@@ -213,8 +242,7 @@ assert(data.relays.length === 2)
|
|||||||
|
|
||||||
## Plumbing
|
## Plumbing
|
||||||
|
|
||||||
1. Install [`just`](https://just.systems/)
|
To develop `nostr-tools`, install [`just`](https://just.systems/) and run `just -l` to see commands available.
|
||||||
2. `just -l`
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user