Documentation
    Preparing search index...

    Interface RelayPoolServiceOptions

    Options for creating a relay pool service.

    const relayPoolService = createRelayPoolService({
    subscribe: (filters, cb, urls) => myPool.subscribe(filters, cb, urls),
    publish: (event) => myPool.publish(event),
    selectRelayTier: (filters) => myPool.selectRelays(filters),
    isAvailable: () => myPool.connected,
    });
    interface RelayPoolServiceOptions {
        isAvailable(): boolean;
        publish(event: NostrEvent): void | Promise<void>;
        publishToRelays?(
            relayUrls: readonly string[],
            event: NostrEvent,
        ): void | Promise<void>;
        selectPublishRelayTier?(): string[];
        selectRelayTier(filters: NostrFilter[]): string[];
        subscribe(
            filters: NostrFilter[],
            callback: (
                item: NostrEvent | "EOSE",
                observedRelayUrls?: string[],
            ) => void,
            relayUrls?: string[],
            fromHint?: boolean,
        ): { unsubscribe(): void };
    }
    Index

    Methods

    • Select relay URLs appropriate for publishing. When omitted, publishing uses selectRelayTier([]) for backwards-compatible selection.

      Returns string[]

      Array of relay URLs

    • Subscribe to events matching filters. Returns handle with unsubscribe().

      Parameters

      • filters: NostrFilter[]

        NIP-01 filter objects

      • callback: (item: NostrEvent | "EOSE", observedRelayUrls?: string[]) => void

        Receives matching events or 'EOSE' plus optional observed relay URLs

      • OptionalrelayUrls: string[]

        Relay URLs the subscription must use: the request's own hint when fromHint is true, otherwise the host tier selected for filters

      • OptionalfromHint: boolean

        True when relayUrls came from an explicit relay hint on the request, which bypasses host relay selection

      Returns { unsubscribe(): void }

      Handle to cancel the subscription