Live JavaScript v1
Live JavaScript
Live
JavaScript
Home
/
Live
/
JavaScript
/
SDK

Create a live event

The first step is to configure the live event by providing a LiveEventCreateParams object. You can provide some basic information related to the event such as the title and the cover image that shows up on the thumbnail. If not specified, the live event ID shows up as the title and the thumbnail shows up as black.

A live event requires a host for which you can provide candidates in the userIdsForHost property. Up to ten users can be set as host candidates and only one of them can act as a host for the live event. When an incumbent host exits the live event, any other users specified in userIdsForHost can enter the live event and act as a host.

Once you have configured the LiveEvent object, you can create a live event by calling the SendbirdLive.createLiveEvent method. If the creation was successful, the status of the live event changes to created and a new open channel becomes available in which the host can chat.

In case the open channel isn’t available, call fetchOpenChannel() to fetch the open channel.

/*
export interface LiveEventCreateParams {
    userIdsForHost?: string[];
    title?: string;
    coverUrl?: string;
    coverFile?: File;
    customType?: string;
}
*/

const params = {
    userIdsForHost: [CURRENT_USER_ID],
    title: 'New Event',
    coverUrl: IMAGE_URL // or coverFile: IMAGE_FILE
}

try {
    await SendbirdLive.createLiveEvent(params);
} catch (e) {
    // Handle error.
}