@nostr-fetch/adapter-ndk
TypeScript icon, indicating that this package has built-in type declarations

0.15.1 • Public • Published

@nostr-fetch/adapter-ndk

This package includes the adapter for NDK(Nostr Dev Kit) which allows it to work with nostr-fetch, a utility library for fetching past events from Nostr relays.

If you want to use nostr-fetch, here is a good start point!

Example

import NDK from '@nostr-dev-kit/ndk';
import { NostrFetcher, normalizeRelayUrlSet } from 'nostr-fetch';
import { ndkAdapter } from '@nostr-fetch/adapter-ndk';

// You should normalize a set of relay URLs by `normalizeRelayUrlSet` before passing them to NDK's constructor if working with nostr-fetch!
const explicitRelays = normalizeRelayUrlSet([
    "wss://relay-jp.nostr.wirednet.jp",
    "wss://relay.damus.io",
]);

const main = async () => {
    const ndk = new NDK({ explicitRelayUrls: explicitRelays });
    await ndk.connect(); // ensure connections to the "explicit relays" before fetching events!

    const fetcher = NostrFetcher.withCustomPool(ndkAdapter(ndk));
    // ...
}

Minimum Supported Version of NDK

adapter version NDK version
< 0.13.0 0.7.5
>= 0.13.0 && < 0.14.1 0.8.4
>= 0.14.1 1.0.0

Readme

Keywords

none

Package Sidebar

Install

npm i @nostr-fetch/adapter-ndk

Weekly Downloads

1

Version

0.15.1

License

MIT

Unpacked Size

116 kB

Total Files

14

Last publish

Collaborators

  • jiftechnify