App-user clients
Build browser or Node app-user flows with VChatClient or the lower-level AppUserClient.
VChatClient or AppUserClient?
Choose VChatClient when one object should own app-user REST, realtime lifecycle, recovery, and channel handles. Choose AppUserClient when you want only the lower-level REST facades and will own lifecycle composition yourself.
Create a lower-level app-user client
import { AppUserClient } from '@vchatsdk/sdk-typescript';
const appUser = new AppUserClient({
baseUrl: 'https://api.example.com',
userId: currentUserId,
tokenProvider: fetchCurrentUserChatToken,
});
const conversations = await appUser.conversations.query({ limit: 25 });
const unread = await appUser.conversations.getUnreadSummary();Messages and read state
const sent = await appUser.messages.send(
'messaging',
'support-123',
{ text: 'Can you help with my account?' },
{ messageId: crypto.randomUUID() },
);
await appUser.channels.markRead(
'messaging',
'support-123',
sent.data.message.messageId,
);The SDK does not synthesize unread counts or treat cached rows as authorization proof. Pass cursors back unchanged and reconcile projection lag or version conflicts through the released reads.
Cancellation and request IDs
const cancellation = new AbortController();
const page = await appUser.conversations.query({
limit: 25,
requestId: 'req_conversations_001',
timeoutMs: 20_000,
signal: cancellation.signal,
});
// Cancel when the owning screen or request is obsolete.
cancellation.abort();