Sign with an extension or remote account
Sign with an extension or remote account
Use nostr-wot-sdk/signers when your app needs an identity and signatures. Nip07Signer uses the installed extension; Nip46Signer connects to a remote signer. Keep one signer for the active session and pass it to other SDK tools.
terminal
$npm install nostr-wot-sdk@3.0.0 nostr-tools
Example
typescript
import { Nip07Signer, isNip07Available } from "nostr-wot-sdk/signers";
// Call from a browser button handler, not during server rendering.
export async function signNote(content: string) {
if (!isNip07Available()) throw new Error("Install or enable a NIP-07 signer");
const signer = new Nip07Signer();
const pubkey = await signer.getPublicKey();
const event = await signer.signEvent({
kind: 1, content, tags: [],
created_at: Math.floor(Date.now() / 1000),
});
if (event.pubkey !== pubkey) throw new Error("Account changed; review again");
return event;
}Integration notes
The example returns a signed note, not a published note. Handle rejection in your button handler and let the user retry explicitly. PrivateKeySigner is for applications that deliberately hold keys themselves; an extension integration does not need to request a seed or private key.