Hiyve Components - v1.0.0
    Preparing search index...
    interface CloudConfig {
        baseUrl?: string;
        cloudToken?: string;
        environment?: CloudEnvironment;
        generateCloudToken?: (
            params: GenerateCloudTokenParams,
        ) => Promise<string | CloudTokenResponse>;
        presence?: boolean | { intervalMs?: number };
        timeout?: number;
        userId?: string;
    }
    Index

    Properties

    baseUrl?: string

    Base URL for the cloud service (overrides environment if provided)

    cloudToken?: string

    Cloud 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.

    environment?: CloudEnvironment

    Environment to connect to.

    • 'production' (default)
    • 'development'
    generateCloudToken?: (
        params: GenerateCloudTokenParams,
    ) => Promise<string | CloudTokenResponse>

    Function to generate/refresh cloud tokens (recommended for browser)

    This function is called:

    • On first request (lazy initialization)
    • When the current token expires

    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 };
    }
    presence?: boolean | { intervalMs?: number }

    Enable 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 interval
    • false / omitted — disabled (default)
    timeout?: number

    Request timeout in milliseconds (default: 30000)

    userId?: string

    The current user's email address.

    Passed to generateCloudToken so the backend can issue a token scoped to this user. Required when using generateCloudToken.