WebSocket Subscriptions
Subscribe to account changes, transaction logs, and signature confirmation over Solana WebSocket JSON-RPC.
Search across all documentation pages
Subscribe to account changes, transaction logs, and signature confirmation over Solana WebSocket JSON-RPC.
Quick-reference recipe card - copy-paste ready.
import { createSolanaRpcSubscriptions, address } from "@solana/kit";
const rpcSubscriptions = createSolanaRpcSubscriptions(
"wss://api.devnet.solana.com"
);
const abort = new AbortController();
const accountNotifications = await rpcSubscriptions
.accountNotifications(address("YOUR_ACCOUNT"), { commitment: "confirmed" })
.subscribe({ abortSignal: abort.signal });
for await (const notification of accountNotifications) {
console.log(notification.value.lamports);
}When to reach for this:
import {
createSolanaRpcSubscriptions,
address,
} from "@solana/kit";
const rpcSubscriptions = createSolanaRpcSubscriptions(
"wss://api.devnet.solana.com"
);
async function watchSignature(signature: string) {
const abort = new AbortController();
const sigNotifications = await rpcSubscriptions
.signatureNotifications(signature, { commitment: "confirmed" })
.subscribe({ abortSignal: abort.signal });
for await (const n of sigNotifications) {
if (n.value.err) {
console.error("failed", n.value.err);
} else {
console.log("confirmed");
}
abort.abort();
break;
}
}
watchSignature("YOUR_TX_SIGNATURE");What this demonstrates:
signatureNotifications resolves when transaction reaches commitment.accountNotifications pushes new account state on writes.AbortController cleans up subscriptions on unmount.*Subscribe JSON-RPC method, receives push *Notification messages.*Unsubscribe.| Method | Fires when |
|---|---|
accountSubscribe | Account lamports/data change |
logsSubscribe | Transaction mentions program/account |
signatureSubscribe | Transaction reaches commitment |
slotSubscribe | New slot processed |
// Logs subscription with mentions filter (provider support varies)
// Use rpcSubscriptions.logsNotifications({ mentions: [programId] })wss:// endpoint from provider docs.confirmed or finalized.| Alternative | Use When | Don't Use When |
|---|---|---|
| HTTP polling | Rare updates, serverless | Sub-second UI reactivity |
| Yellowstone gRPC | Indexer throughput | Simple wallet app |
| Webhooks (Helius) | Server-side ingestion | Pure browser client |
solana logs CLI | Developer debugging | Production user features |
Often wss://api.devnet.solana.com - confirm with your provider; may differ from HTTPS host.
Provider-specific - batch related accounts or use server-side indexer for hundreds.
Use createSolanaRpcSubscriptions log notification APIs - see kit docs for exact method names on your version pin.
Yes - ws://127.0.0.1:8900 or provider-documented local WS port while test-validator runs.
Abort the async iterator or call unsubscribe RPC with subscription id from kit internals.
Account may change multiple times per slot - dedupe by slot or lamports equality in UI.
Subscribe is lower latency and less RPC load than tight polling loops.
Poor fit - connections are long-lived; use webhooks or polling on serverless.
Filter to transactions referencing a program or account pubkey - reduces noise.
Useful for slot-driven UI clocks and coordinating reads at slot boundaries.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026