Class NDKNip46Signer

This NDKSigner implements NIP-46, which allows remote signing of events. This class is meant to be used client-side, paired with the NDKNip46Backend or a NIP-46 backend (like Nostr-Connect)


authUrl -- Emitted when the user should take an action in certain URL. When a client receives this event, it should direct the user to go to that URL to authorize the application.


const ndk = new NDK()
const nip05 = await prompt("enter your nip-05") // Get a NIP-05 the user wants to login with
const privateKey = localStorage.getItem("nip46-local-key") // If we have a private key previously saved, use it
const signer = new NDKNip46Signer(ndk, nip05, privateKey) // Create a signer with (or without) a private key

// Save generated private key for future use
localStorage.setItem("nip46-local-key", signer.localSigner.privateKey)

// If the backend sends an auth_url event, open that URL as a popup so the user can authorize the app
signer.on("authUrl", (url) => {, "auth", "width=600,height=600") })

// wait until the signer is ready
const loggedinUser = await signer.blockUntilReady()

alert("You are now logged in as " + loggedinUser.npub)


  • EventEmitter
    • NDKNip46Signer




localSigner: NDKSigner
relayUrls: string[] = []
remotePubkey: undefined | string
remoteUser: NDKUser
token: undefined | string


  • Allows creating a new account on the remote server.


    • Optional username: string

      Desired username for the NIP-05

    • Optional domain: string

      Desired domain for the NIP-05

    • Optional email: string

      Email address to associate with this account -- Remote servers may use this for recovery

    Returns Promise<string>

    The public key of the newly created account

  • Encrypts the given Nostr event for the given recipient.


    • recipient: NDKUser

      The recipient of the encrypted value.

    • value: string

      The value to be encrypted.

    Returns Promise<string>

Generated using TypeDoc