Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

Rust

The Rust crates are published on crates.io as nostr and nostr-sdk. For protocol-only code:

[dependencies]
nostr = "0.45"

For a networked application:

[dependencies]
nostr-sdk = "0.45"

Both crates require Rust 1.85 or later. Start with default features; chapters that require another crate or an opt-in feature show it where it is used. See nostr and nostr-sdk feature lists.

Python

Python 3.9 or later is required. Install the package from PyPI:

pip install nostr-sdk==0.45.1

Supported platforms

Prebuilt wheels contain the native library for these targets:

OSx86_64aarch64armv7i686riscv64
Android
Linux (GLIBC)
Linux (MUSL)
FreeBSD
macOS
Windows

No running event loop

Normal client calls work inside asyncio.run. A custom database, websocket implementation, or admission policy can be called from an SDK-owned thread instead. If an asynchronous callback fails with no running event loop, register the application loop before constructing that callback:

import asyncio
from typing import cast

from nostr_sdk import uniffi_set_event_loop


async def configure_event_loop() -> None:
    loop = cast(asyncio.BaseEventLoop, asyncio.get_running_loop())
    uniffi_set_event_loop(loop)

Call this from inside the application’s running async entry point, not at module import time.

JavaScript

Install exactly one package for the target runtime from the NostrDevKit npm organization.

Node.js
npm install @nostrdevkit/nostr-sdk-node@0.45.1

Node.js 20 or later is required.

OSx86_64aarch64armv7i686riscv64
Android
iOS
Linux (GLIBC)
Linux (MUSL)
FreeBSD
macOS
Windows
Web
npm install @nostrdevkit/nostr-sdk-web@0.45.1

Use a bundler that emits the package’s WebAssembly asset. Call await uniffiInitAsync() once before constructing any generated SDK type.

RuntimeSupported
Web browsers
Node.js
React Native
React Native
npm install @nostrdevkit/nostr-sdk-react-native@0.45.1

React Native 0.76 or later with the New Architecture enabled is required.

Platformx86_64aarch64armv7i686
Android
iOS device
iOS simulator
Kotlin

Select one artifact for the application target:

dependencies {
    implementation("org.nostrdevkit:nostr-sdk:0.45.1")     // Android, minSdk 21
    implementation("org.nostrdevkit:nostr-sdk-jvm:0.45.1") // JVM 11+
    implementation("org.nostrdevkit:nostr-sdk-kmp:0.45.1") // Kotlin Multiplatform
}

Types are imported from org.nostrdevkit.sdk. The Android artifact requires API 21 or later, the standalone JVM artifact requires Java 11 or later, and the KMP JVM target requires Java 17.

Supported platforms

OSx86_64aarch64armv7i686riscv64Package
Androidnostr-sdk, nostr-sdk-kmp
iOSnostr-sdk-kmp
Linux (GLIBC)nostr-sdk-jvm, nostr-sdk-kmp
Linux (MUSL)nostr-sdk-jvm, nostr-sdk-kmp
FreeBSDnostr-sdk-jvm, nostr-sdk-kmp
macOSnostr-sdk-jvm, nostr-sdk-kmp
Windowsnostr-sdk-jvm, nostr-sdk-kmp

JNA dependency

Some Gradle configurations do not expose the binding’s JNA dependency to application code. If compilation fails with class file for com.sun.jna.Pointer not found, add JNA explicitly for the selected target:

dependencies {
    implementation("net.java.dev.jna:jna:5.17.0@aar") // Android
    implementation("net.java.dev.jna:jna:5.15.0")     // JVM
}

Use only the line matching the target. Kotlin Multiplatform projects should add the JVM dependency to jvmMain and the AAR variant to androidMain.

Swift

Add the nostr-sdk-swift repository in Xcode, or declare the package directly:

.package(url: "https://github.com/nostrdevkit/nostr-sdk-swift", exact: "0.45.1")

Supported platforms

OSx86_64aarch64armv7i686
iOS 14+ device
iOS Simulator
Mac Catalyst
macOS 12+
visionOS
watchOS
tvOS
C#

.NET 6 or later is required. Install the package from NuGet:

dotnet add package Nostr.Sdk --version 0.45.1

Supported platforms

OSx86_64aarch64armv7i686riscv64
Android
iOS device
iOS Simulator
Linux (GLIBC)
Linux (MUSL)
FreeBSD
macOS
Windows

Continue with Hello, Nostr! once the package is available to the project.