Client SDK reference
Every method and event of @lynkoria/client, for browsers and JavaScript apps.
import { createLynkoria } from '@lynkoria/client';
const client = createLynkoria({
baseUrl: 'https://api.lynkoria.com',
getMessagingToken: () => fetchTokenFromYourBackend(), // string or { token, expiresAt }
// Optional:
fetch, // custom fetch (React Native, tests)
ids: { create: () => uuid() }, // when crypto.randomUUID is unavailable
socketPath: '/socket.io/',
heartbeatMs: 25_000,
});Connection
| Member | Description |
|---|---|
connect() | Opens the realtime socket (WebSocket only) and keeps it open with backoff and jitter. |
disconnect() | Closes it and stops reconnecting. |
connectionState | idle, connecting, connected, reconnecting or disconnected. |
onConnectionState(listener) | Returns an unsubscribe function. |
onError(listener) | Background errors (refresh failures, resync failures, rejected handshakes) as LynkoriaError. |
Every on… method returns a function that removes the listener.
Messages
| Method | Returns |
|---|---|
messages.history(conversationId, { beforeSeq?, limit? }) | { items, lastSeq, hasMore } (default 50) |
messages.send({ conversationId, text?, attachmentIds?, parentMessageId?, clientMessageId? }) | Message |
messages.edit(messageId, text) | Message |
messages.delete(messageId) | void |
messages.react(messageId, emoji) / unreact(messageId, emoji) | void |
messages.markRead(conversationId, seq) | { readSeq } |
onMessage(listener) | Ordered, deduplicated ConversationEvents |
onRead(listener) | { conversationId, userId, seq } |
send uses the socket when connected and falls back to REST with the same clientMessageId after an acknowledgement timeout, so a retry cannot duplicate a message.
Conversations
| Method | Description |
|---|---|
conversations.list({ limit?, cursor? }) | { items, nextCursor } for the signed-in user. |
conversations.track(id, lastSeq) | Start ordered delivery from a known sequence. |
conversations.untrack(id) | Stop tracking. |
conversations.resync(id) | Fetch and replay everything after the last applied seq. |
onConversationUpdated(listener) | { conversationId, reason: 'members_changed' | 'removed' } |
Presence and typing
| Method | Description |
|---|---|
presence.subscribe(userId, listener) | Live Presence updates; returns unsubscribe. |
presence.get(userId) | One-off Presence over REST. |
presence.setStatus(status) | available, away, busy, dnd or invisible. |
onPresenceChange(listener) | Every presence change this client receives. |
typing.start(conversationId) | Throttled to one event per 3 seconds. |
typing.stop(conversationId) | |
onTyping(listener) | { conversationId, userId, typing } |
Attachments
| Method | Returns |
|---|---|
attachments.upload(conversationId, blob, name) | Attachment (direct presigned upload, then verified) |
attachments.downloadUrl(attachmentId) | { url, expiresAt } |
Calls
| Member | Description |
|---|---|
calls.join({ getJoinToken, roomOptions?, connectOptions? }) | Loads livekit-client on demand, connects, returns a CallSession. |
onCallStateChange(listener) | Call signals: { type: 'invited' | 'ringing' | 'accepted' | 'declined' | 'ended', … } |
CallSession:
| Member | Description |
|---|---|
room | The LiveKit Room for rendering. |
state | connecting, connected, reconnecting, disconnected. |
setMicrophoneEnabled(bool) / setCameraEnabled(bool) | Publish or mute. |
startScreenShare() / stopScreenShare() | Screen capture. |
onStateChange(listener) | Media connection state changes. |
participants | CallParticipant[] snapshot, local participant first. |
onParticipantsChange(listener) | Joins, leaves, mute/camera/screen, speaking and quality. |
listDevices(kind) / switchDevice(kind, deviceId) | audioinput, audiooutput or videoinput selection. |
leave() | Disconnect this device. |
A CallParticipant has identity (project:user:device), name, isLocal, isMicrophoneEnabled, isCameraEnabled, isScreenShareEnabled, isSpeaking and connectionQuality (excellent, good, poor, lost or unknown).
Utilities
client.ids.create() returns a unique ID suitable for clientMessageId. jwtExpiry(token) reads a token’s expiry without verifying it. SequenceTracker implements the ordering rules for custom stores.
API reference
Every export with its signature, generated from the package build: client reference.