Nostr SDK
Description
A full-featured SDK for building high-performance and reliable nostr applications.
The SDK can be used to build both sides of a nostr application:
- clients, bots, and services that connect to existing relays;
- local relays that run inside your process, including mock relays for tests.
Getting started
Client
use ;
use *;
async
Local Relay
The local-relay feature enables in-process relays without re-implementing policies, storage, or protocol handling.
LocalRelayruns a fully fledged relay inside your process.MockRelayruns an ephemeral relay for unit and integration tests.
use Duration;
use *;
async
More examples can be found in the examples directory.
Crate Feature Flags
The following crate feature flags are available:
| Feature | Default | Description |
|---|---|---|
ring |
Yes | Enable ring crypto provider |
rustls-tls-webpki-roots |
Yes | Enable rustls with bundled Mozilla root certs |
aws_lc_rs |
No | Enable aws-lc-rs crypto provider |
native-tls |
No | Enable platform-native TLS |
native-tls-vendored |
No | Enable platform-native TLS with vendored OpenSSL |
rustls-tls-native-roots |
No | Enable rustls with platform-native root certs |
local-relay |
No | Enable nostr_sdk::local_relay module |
Local Relay supported NIPs
Legend:
- ✅ Fully supported
- 🔧 Depends on the database implementation
- ❌ Not supported
*: The relay does not accept or send expired events. The database has to delete them.
WASM
This crate supports the wasm32 targets.
An example can be found at nostr-sdk-wasm-example repo.
On macOS, you need to install llvm:
brew install llvm
LLVM_PATH=$(brew --prefix llvm)
AR="${LLVM_PATH}/bin/llvm-ar" CC="${LLVM_PATH}/bin/clang" cargo build --target wasm32-unknown-unknown
NOTE: Currently nip03 feature not support WASM.
Changelog
All notable changes to this library are documented in the CHANGELOG.md.
State
This library is in an ALPHA state, things that are implemented generally work, but the API will change in breaking ways.
Donations
Nostr Dev Kit 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 libs/software/services, then please donate.
License
This project is distributed under the MIT software license – see the LICENSE file for details