Skip to main content

ActivityClient

ActivityClient is a virtual view over all threads a wallet has participated in. It queries Light Protocol's compressed account index — no separate on-chain account needs to be created.

Access it via client.activity():

const activity = client.activity();
await activity.load();

const threads = await activity.loadThreads({ limit: 20 });

Static Methods

ActivityClient.Load({ client, owner? })

Loads compressed thread accounts for the given owner.

const activity = await ActivityClient.Load({
client,
owner: wallet.publicKey, // defaults to connected wallet
});

Returns Promise<ActivityClient>


Instance Methods

activity.load(options?)

Fetches compressed thread accounts from the index. Safe to call multiple times — subsequent calls are incremental by default.

await activity.load();
FieldTypeDefaultDescription
pageLimitnumber100Compressed accounts per RPC page
maxPagesnumberunlimitedStop after this many RPC pages
incrementalbooleanfalseContinue from last cursor instead of rebuilding

Returns Promise<this>


activity.refresh(options?)

Re-fetches thread accounts. Use incremental: true to append new results, or clearPages: true to start over.

// Pick up new threads since last load
await activity.refresh({ incremental: true });

// Full reload
await activity.refresh({ clearPages: true });

Returns Promise<this>


activity.loadThreads(options?)

Returns ThreadClient instances for all tracked threads, sorted by recency. Fetches from the index if not already loaded.

const threads = await activity.loadThreads({
limit: 30,
includeLastMessage: true,
});
FieldTypeDescription
offsetnumberSkip the first N results
limitnumberMax threads to return
includeLastMessagebooleanAlso load the last message for each thread
concurrentFetchLimitnumberMax parallel thread fetches (default 10)
concurrentMessageFetchLimitnumberMax parallel last-message fetches (default 10)
pageLimitnumberCompressed accounts per RPC page
maxPagesnumberMax RPC pages to walk
incrementalbooleanAppend new results instead of reloading
inboxInbox | InboxClientShared inbox to attach to all returned threads

Returns Promise<ThreadClient[]>


activity.loadThreadsAcrossHistory(options)

Loads a bounded history of threads, walking back through multiple RPC pages until the limit is met.

const threads = await activity.loadThreadsAcrossHistory({
limit: 50,
includeLastMessage: true,
maxPages: 5,
});
FieldTypeDescription
limitnumberTarget thread count
includeLastMessagebooleanPre-load last message
maxPagesnumberMax RPC pages (default 5)
pageLimitnumberCompressed accounts per page
concurrentFetchLimitnumberParallel thread fetches
concurrentMessageFetchLimitnumberParallel message fetches

Returns Promise<ThreadClient[]>


activity.exists()

Returns true if the wallet has any threads.

if (await activity.exists()) {
const threads = await activity.loadThreads({ limit: 20 });
}

Returns Promise<boolean>


activity.getThreadAccounts(options?)

Returns raw decoded thread account data without creating ThreadClient instances. Useful for lightweight reads.

FieldTypeDescription
offsetnumberSkip the first N results
limitnumberMax accounts to return

Returns DecodedThreadAccount[]


Properties

PropertyTypeDescription
ownerPublicKeyThe wallet this activity belongs to
lennumberNumber of unique threads currently in the local index
cursorsStateActivityCursorStateCurrent RPC pagination cursors (for incremental loads)

ActivityCursorState

type ActivityCursorState = {
from?: string;
to?: string;
};

Tracks cursor positions for the two scan directions (from and to). Used internally for incremental loading.