Expand description
Browser-compatible Holochain client for Leptos frontends.
Replaces @holochain/client (JavaScript) for Rust WASM frontends.
Uses web-sys::WebSocket + rmp-serde (MessagePack) to communicate
with a Holochain conductor over binary WebSocket frames.
§Architecture
The crate is built around the HolochainTransport trait, which abstracts
the underlying communication mechanism. Two implementations are provided:
BrowserWsTransport— Usesweb-sys::WebSocketfor browser WASM targetsTauriIpcTransport— (future) Calls Tauri backend viawasm-bindgeninvoke()
The HolochainClient type wraps any transport and provides a typed,
ergonomic API for calling zome functions with automatic MessagePack
serialization/deserialization.
§Example
ⓘ
use mycelix_leptos_client::{HolochainClient, BrowserWsTransport};
use serde::{Serialize, Deserialize};
#[derive(Serialize)]
struct CreateProposal { title: String, body: String }
#[derive(Deserialize)]
struct ProposalHash { hash: Vec<u8> }
async fn example() {
let transport = BrowserWsTransport::new();
let client = HolochainClient::new(transport, "mycelix-unified", "governance");
// Connect with optional auth token (None = no authentication)
client.connect("ws://localhost:8888", None).await.unwrap();
let result: ProposalHash = client.call_zome(
"agora",
"create_proposal",
&CreateProposal { title: "Test".into(), body: "Body".into() },
).await.unwrap();
}Re-exports§
pub use client::HolochainClient;pub use error::ClientError;pub use mock::MockTransport;pub use transport::HolochainTransport;pub use types::decode;pub use types::encode;pub use types::ConnectConfig;pub use types::ConnectionStatus;pub use types::ReconnectConfig;pub use types::ZomeCallRequest;pub use types::ZomeCallResponse;pub use browser::BrowserWsTransport;
Modules§
- browser
- Browser WebSocket transport for Holochain conductor communication.
- client
- High-level Holochain client wrapping a transport.
- error
- Error types for the Holochain browser client.
- mock
- Mock transport for demo/development mode.
- transport
- Transport trait abstracting the communication mechanism with a Holochain conductor.
- types
- Core types for the Holochain browser client.