---
title: "Pubky SDK: Client Libraries for Decentralized Applications"
---

:::note
The SDK is now at **v0.10**. If you're upgrading from an earlier version, see the [v0.10 Migration Guide](https://github.com/pubky/pubky-homeserver/tree/main/docs/v0.10-migration).
:::

The Pubky SDK provides client libraries for building applications on [Pubky Core](https://pubky.org/explore/pubkycore/introduction.md). 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](https://pubky.org/explore/pubkycore/introduction.md) for background on identities, homeservers, and storage paths. For a hands-on walkthrough, see the [Developer Guide](https://pubky.org/explore/pubkycore/getting-started.md).

## Supported Platforms

| Platform | Language | Status | Package |
|----------|----------|--------|---------|
| **Rust** | Rust | ✅ Stable | [crates.io/crates/pubky](https://crates.io/crates/pubky) |
| **Web/Node** | JavaScript/TypeScript | ✅ Stable | [@synonymdev/pubky](https://www.npmjs.com/package/@synonymdev/pubky) |
| **React Native** | JavaScript/TypeScript | ✅ Stable | [@synonymdev/react-native-pubky](https://www.npmjs.com/package/@synonymdev/react-native-pubky) |
| **iOS** | Swift | 🚧 Beta | [pubky-core-ffi](https://github.com/pubky/pubky-core-ffi) |
| **Android** | Kotlin | 🚧 Beta | [pubky-core-ffi](https://github.com/pubky/pubky-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.

## API Reference

- **Rust**: [docs.rs/pubky](https://docs.rs/pubky)
- **JavaScript/TypeScript**: [TypeDoc Reference](https://pubky.github.io/pubky-homeserver/js-sdk-typedoc/)
- **HTTP API**: [Endpoint specification](https://pubky.org/explore/pubkycore/api.md)

## How It Works

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.

## Quick Example

Sign in and read/write data. Account creation (signup) is generally handled outside of your app. See the [Developer Guide](https://pubky.org/explore/pubkycore/getting-started.md) for testnet setup where you bootstrap accounts for development.

**Rust:**
```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:**
```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");
```

## Resources

- **Repository**: [github.com/pubky/pubky-homeserver](https://github.com/pubky/pubky-homeserver)
- **Examples**: [Full working examples](https://github.com/pubky/pubky-homeserver/tree/main/examples) covering testnet setup, signup, auth flows, CRUD operations, and event streaming
