Skip to content

Pubky SDK: Client Libraries for Decentralized Applications

The Pubky SDK provides client libraries for building applications on Pubky Core. It handles the hard parts (key-based auth, homeserver discovery, transport) so you can focus on your app logic using familiar HTTP-style operations.

New to Pubky? Start with the Introduction for background on identities, homeservers, and storage paths. For a hands-on walkthrough, see the Developer Guide.

PlatformLanguageStatusPackage
RustRust✅ Stablecrates.io/crates/pubky
Web/NodeJavaScript/TypeScript✅ Stable@synonymdev/pubky
React NativeJavaScript/TypeScript✅ Stable@synonymdev/react-native-pubky
iOSSwift🚧 Betapubky-core-ffi
AndroidKotlin🚧 Betapubky-core-ffi

All platforms share a consistent API surface. The React Native SDK uses mobile-optimized UniFFI bindings but exposes the same API as the JavaScript SDK.

The SDK is organized around a small set of actors that mirror the developer workflow:

  1. Pubky — Your top-level client. Create one at startup and share it across your app. It manages the HTTP client, connection pool, and homeserver resolution via PKARR. It then hands off authenticated work to signers and sessions.

  2. PubkySigner — Holds a private key and proves identity. Use it to sign up for a homeserver, sign in, or approve auth requests from other apps.

  3. PubkySession — Your authenticated handle after signing in. Thread-safe, cheap to clone, and carries your credentials. Supports export/restore for surviving process restarts.

  4. SessionStorage — Read and write your data with simple path-based operations (get, put, delete, list). The SDK resolves homeservers and attaches credentials automatically.

  5. PublicStorage — Read anyone’s public data without signing in. No keys or session needed.

For event-driven apps, EventStreamBuilder lets you subscribe to real-time changes via SSE. Pkdns handles discovery of users’ homeservers via PKARR records. GrantManager provides admin-level permission management.

Sign in and read/write data. Account creation (signup) is generally handled outside of your app. See the Developer Guide for testnet setup where you bootstrap accounts for development.

Rust:

use pubky::{ClientId, Keypair, Pubky};
let pubky = Pubky::new()?;
let keypair = Keypair::random();
// Sign in (user already has an account on a homeserver)
let signer = pubky.signer(keypair);
let session = signer
.signin(ClientId::new("myapp.example").unwrap())
.await?;
// Write data (requires the "json" feature)
let profile = serde_json::json!({"name": "Alice", "bio": "Building on Pubky!"});
session
.storage()
.put_json("/pub/myapp/profile", &profile)
.await?;
// Read data
let profile: serde_json::Value = session.storage().get_json("/pub/myapp/profile").await?;

JavaScript:

const pubky = new Pubky();
const keypair = Keypair.random();
// Sign in (user already has an account on a homeserver)
const signer = pubky.signer(keypair);
const session = await signer.signin("myapp.example");
// Write data
await session.storage.putJson("/pub/myapp/profile", {
name: "Alice",
bio: "Building on Pubky!",
});
// Read data
const profile = await session.storage.getJson("/pub/myapp/profile");