Skip to content

Initialize Client

To interact with Pubky homeservers, you need to create a Pubky instance. The Pubky facade is the main entry point for the SDK and owns the transport layer.

Basic Client

fn init_client() -> pubky::Result<Pubky> {
    let pubky = Pubky::new()?;
    Ok(pubky)
}

Testnet Mode

For development and testing, you can use testnet mode which connects to test homeservers:

fn init_client_testnet() -> pubky::Result<Pubky> {
    // Create a client configured for testnet mode
    let pubky = Pubky::testnet()?;
    Ok(pubky)
}

The testnet mode is useful for development without affecting production data or requiring production homeserver access.