← All NIPs

NIP-07

window.nostr capability for web browsers

DraftBehaviour

A browser extension exposes window.nostr so websites can get your public key, sign events and encrypt messages without ever seeing your secret key.

At a glance

Status
In use and still allowed to change.
Last changed
Feb 14, 2025

Try it

Edit the form or the JSON: both stay in sync, the badge says whether the result is valid, and tapping any field explains it.

How this NIP works

Step 1 of 5

Keys stay in the extension

Web apps never touch your nsec. They ask the extension, which asks you.

Who does what

Who does what
YouWeb appSigner extension
Step 1 of 8

Ready. Press play or step forward to send the first message.

Text version
#FromToMessage
1Web appWeb appThe app checks for the object before offering "log in with extension".
2Web appSigner extensionThe app asks who you are.
3Signer extensionYouThe extension asks you whether this site may use your key.
4Signer extensionWeb appThe extension returns the hex pubkey.
5Web appSigner extensionThe app hands over an unsigned template.
6Signer extensionWeb apppubkey, id and sig are filled in; the app can publish it.
7Web appSigner extensionOptional: the app asks for ciphertext for a DM.

In the course

Builds on

See also

Specification

Specification text is quoted in English from the nostr-protocol/nips repository. Our explanations and the interface are translated. Source on GitHub at commit 0046368

Read the spec189 words, quoted from the repository at commit 0046368.

The window.nostr object may be made available by web browsers or extensions and websites or web-apps may make use of it after checking its availability.

That object must define the following methods:

async window.nostr.getPublicKey(): string // returns a public key as hex
async window.nostr.signEvent(event: { created_at: number, kind: number, tags: string[][], content: string }): Event // takes an event object, adds `id`, `pubkey` and `sig` and returns it

Aside from these two basic above, the following functions can also be implemented optionally:

async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext and iv as specified in nip-04 (deprecated)
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 (deprecated)
async window.nostr.nip44.encrypt(pubkey, plaintext): string // returns ciphertext as specified in nip-44
async window.nostr.nip44.decrypt(pubkey, ciphertext): string // takes ciphertext as specified in nip-44

Recommendation to Extension Authors

To make sure that the window.nostr is available to nostr clients on page load, the authors who create Chromium and Firefox extensions should load their scripts by specifying "run_at": "document_end" in the extension's manifest.

Implementation

See https://github.com/aljazceru/awesome-nostr#nip-07-browser-extensions.