Skip to content

Nostrify with Welshman ​

Welshman is a Nostr library by Coracle.

It uses a powerful relay selection algorithm to choose the best relays for each request, enabling outbox support and more.

WARNING

Welshman is still in development and may not be stable.

Installation ​

You will need the @nostrify/welshman package.

sh
npx jsr add @nostrify/welshman
sh
deno add @nostrify/welshman
sh
yarn dlx jsr add @nostrify/welshman
sh
pnpm dlx jsr add @nostrify/welshman
sh
bunx jsr add @nostrify/welshman

Usage ​

The NWelshman class is a relay pool that accepts a Welshman Router object.

ts
import { NWelshman } from '@nostrify/welshman';

const pool = new NWelshman(router);

Router ​

The Router class comes from Welshman itself. Here is a template to get you started:

ts
import { Router, RelayMode } from '@welshman/util';

const router = new Router({
  getUserPubkey: (): string | null => null,
  getGroupRelays: (address: string): string[] => [],
  getCommunityRelays: (address: string): string[] => [],
  getPubkeyRelays: (pubkey: string, mode?: RelayMode): string[] => [],
  getStaticRelays: (): string[] => [],
  getIndexerRelays: (): string[] => [],
  getSearchRelays: (): string[] => [],
  getRelayQuality: (url: string): number => 1,
  getRedundancy: (): number => 2,
  getLimit: (): number => 10,
});

See a detailed explanation of each option here.

Soapbox