OptionalbaseOptionalcloudCloud token for browser-safe authentication (recommended)
Obtain this token from your backend by calling the /cloud-token
endpoint with your API key. Tokens are short-lived (default 24h)
and include a ct_ prefix.
OptionalenvironmentEnvironment to connect to.
'production' (default)'development'OptionalgenerateFunction to generate/refresh cloud tokens (recommended for browser)
This function is called:
The SDK passes { userId } so the callback can forward it to the
backend token endpoint. Can return either a token string or
{ cloudToken, environment } for automatic environment detection.
async function generateCloudToken({ userId }: { userId: string }) {
const response = await fetch('/api/generate-cloud-token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userId }),
});
const { cloudToken, environment } = await response.json();
return { cloudToken, environment };
}
OptionalpresenceEnable automatic presence heartbeat.
When enabled, the client periodically signals the server that this
user is online. The heartbeat starts when a userId is set (via
setUserId() or config) and stops when the client is destroyed.
true — enable with default interval (10 000 ms){ intervalMs: number } — enable with custom intervalfalse / omitted — disabled (default)OptionaltimeoutRequest timeout in milliseconds (default: 30000)
OptionaluserThe current user's email address.
Passed to generateCloudToken so the backend can issue a token
scoped to this user. Required when using generateCloudToken.
Base URL for the cloud service (overrides environment if provided)