Post, reply and react using your own account
These functions turn a message into a real Nostr event, ask your signer to approve it, send it to relays, and fetch it back. Replies and reactions keep links to the original message.
const pubkey = await signer.getPublicKey();
const relays = discovered.relays;
const posted = await Nostr.publishTemplate(Nostr.textNote('Hello'), {
signer, pubkey, relays,
});
const replied = await Nostr.publishTemplate(
Nostr.textNote('Reply!', { replyTo: posted.event }),
{ signer, pubkey, relays }
);
const liked = await Nostr.publishTemplate(
Nostr.reaction(posted.event, '+'),
{ signer, pubkey, relays }
);
Check the resulting receipts rather than assuming success from a successful signing prompt alone. This example requires real signer approval and real relay destinations.
Read the feed
const result = await Nostr.fetchFeed({
authors: [pubkey],
relays,
kinds: [1, 7],
limit: 50,
});
console.log(result.events, result.failed, result.status);
fetchFeed deduplicates verified events. On account switch, dispose any host-owned subscriptions and stop old-account state from writing into the new profile. See Deepink recipe.