JavaScript bindings of nostr library.
If you're writing a typical Nostr client or bot, you may be interested in nostr-sdk.
This library should work on every JavaScript environment (nodejs, web, react native, ...).
npm i @rust-nostr/nostr
const { Keys, loadWasmAsync } = require("@rust-nostr/nostr");
async function main() {
// Load WASM
// if you are in a non async context, use loadWasmSync()
await loadWasmAsync();
// Generate random keys
let keys = Keys.generate();
// Hex keys
console.log("Public key (hex): ", keys.publicKey.toHex());
console.log("Secret key (hex): ", keys.secretKey.toHex());
// Bech32 keys
console.log("Public key (bech32): ", keys.publicKey.toBech32());
console.log("Secret key (bech32): ", keys.secretKey.toBech32());
}
main();
More examples can be found in the examples directory.
Look at https://github.com/rust-nostr/nostr/tree/master/crates/nostr#supported-nips (the Js library could be out of sync with the supported NIPs in the nostr
rust crate)
Learn more about rust-nostr
at https://rust-nostr.org.
This library is in an ALPHA state, things that are implemented generally work but the API will change in breaking ways.
rust-nostr
is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the rust-nostr
libs/software/services, then please donate.
This project is distributed under the MIT software license - see the LICENSE file for details