Relay management
RelayPool wraps a compatible PoolLike transport supplied by your app. Configure urls, use subscribe with onEvent/onEose, and close subscriptions when finished. A separately created relay wrapper is not automatically connected to the data provider.
terminal
$npm install nostr-wot-sdk@3.0.0 nostr-tools
typescript
import { RelayPool, type PoolLike, type NostrEvent } from "nostr-wot-sdk/relay";
function watchNotes(transport: PoolLike, onEvent: (event: NostrEvent) => void) {
const pool = new RelayPool({
urls: ["wss://relay.damus.io", "wss://nos.lol"],
pool: transport,
});
const sub = pool.subscribe({ kinds: [1], limit: 50 }, { onEvent });
return () => {
sub.close();
pool.destroy();
};
}