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/welshmansh
deno add jsr:@nostrify/welshmansh
yarn add jsr:@nostrify/welshmansh
pnpm add jsr:@nostrify/welshmansh
bunx jsr add @nostrify/welshmanUsage ​
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 { RelayMode, Router } 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.