> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Go Live & Room Management

> Create broadcast rooms, connect to LiveKit, monitor room lifecycle, query live rooms, and access recordings.

> [!NOTE]
>
> **SDK v7.x** · Last verified March 2026 · iOS · Android · Web

> [accordion] Speed run — just the code
>
> ```typescript theme={null}
> import { RoomRepository, PostRepository } from '@amityco/ts-sdk';
> import { Room as LiveKitRoom } from 'livekit-client';
>
> // 1. Create a room with live chat enabled
> const { data: room } = await RoomRepository.createRoom({
>   title: 'Friday AMA', channelEnabled: true,
> });
>
> // 2. Publish a livestream post
> await PostRepository.createPost({
>   targetType: 'community', targetId: communityId,
>   dataType: 'livestream', data: { streamId: room.roomId },
> });
>
> // 3. Get broadcaster credentials & connect
> const bd = await RoomRepository.getBroadcasterData(room.roomId);
> const lk = new LiveKitRoom();
> await lk.connect(bd.coHostUrl, bd.coHostToken);
> await lk.localParticipant.setCameraEnabled(true);
> await lk.localParticipant.setMicrophoneEnabled(true);
>
> // 4. Stop & get recording
> await lk.disconnect();
> await RoomRepository.stopRoom(room.roomId);
> ```
>
> Full walkthrough below ↓

> [!TIP]
>
> **Platform note** — code samples below use TypeScript. Every method has an equivalent in the iOS (Swift) and Android (Kotlin) SDKs — see the linked SDK reference in each step.

![Host broadcasting a livestream with live chat messages and reactions visible](https://mintcdn.com/social-b97141fb-auto-generate-llmstxt/HK8-O4u_NqMeCf6h/images/Livestream\(4\).png?fit=max\&auto=format\&n=HK8-O4u_NqMeCf6h\&q=85\&s=70289d3119d75a1daeaea4c118e0336f)

Host broadcasting with live chat overlay

This guide covers the host's journey: create a room, wire up the broadcast, monitor lifecycle transitions, query live rooms for a "Live Now" section, and access recordings after the stream ends.

```mermaid theme={null}
sequenceDiagram
    participant Host
    participant SDK as social.plus SDK
    participant LK as LiveKit
    participant Viewers

    Host->>SDK: createRoom()
    SDK-->>Host: room (IDLE)
    Host->>SDK: createPost(livestream)
    Host->>SDK: getBroadcastData(roomId)
    SDK-->>Host: coHostUrl + coHostToken
    Host->>LK: connect(url, token)
    Host->>LK: setCameraEnabled(true)
    Note over Host,LK: Room is now LIVE
    Viewers->>LK: Watch stream
    Host->>LK: disconnect()
    Host->>SDK: stop(roomId)
    Note over SDK: Room → ENDED → RECORDED
    Viewers->>SDK: getRecordedUrls(roomId)
```

> [!NOTE]
>
> **Prerequisites**: SDK + Video SDK installed and authenticated → [Video Getting Started](/social-plus-sdk/video-new/broadcasting/overview.md). A `communityId` is required — rooms are community-only.

***

## Quick Start: Create a Room and Go Live

```typescript theme={null}
const { data: room } = await RoomRepository.createRoom({
  title: 'Product Launch Event',
  description: 'Join us for the unveiling',
  channelEnabled: true,  // auto-creates a live chat channel
});
console.log('Room created:', room.roomId, '— status:', room.status); // IDLE
```

Full reference → [Create Room](/social-plus-sdk/video-new/broadcasting/create-room.md)

***

## Step-by-Step Implementation

**1. Create a broadcast room**

A room is the container for a livestream session. Set `channelEnabled: true` to automatically create a live chat channel for viewer comments.

```typescript theme={null}
import { RoomRepository } from '@amityco/ts-sdk';

const { data: room } = await RoomRepository.createRoom({
  title: 'Weekly Q&A Session',
  description: 'Ask us anything',
  thumbnailFileId: null,
  metadata: { category: 'education' },
  channelEnabled: true,
  parentRoomId: null,
});
```

Full reference → [Create Room](/social-plus-sdk/video-new/broadcasting/create-room.md)

**2. Publish a livestream post**

Create a post in the community feed that links to the room. This shows a "LIVE" badge in the feed while the room is broadcasting.

```typescript theme={null}
import { PostRepository, PostContentType } from '@amityco/ts-sdk';

const { data: post } = await PostRepository.createPost({
  dataType: PostContentType.LIVESTREAM,
  targetType: 'community',
  targetId: communityId,
  data: { text: 'We are live!', streamId: room.roomId },
});
```

Full reference → [Live Stream Post](/social-plus-sdk/social/content-management/posts/creation/live-stream-post.md)

**3. Get broadcaster credentials and connect to LiveKit**

Fetch the LiveKit URL and token, then connect the host's camera and microphone.

```typescript theme={null}
import { Room as LiveKitRoom, RoomEvent } from 'livekit-client';

const broadcastData = await RoomRepository.getBroadcasterData(room.roomId);

const liveKitRoom = new LiveKitRoom();
liveKitRoom.on(RoomEvent.Connected, () => console.log('Connected!'));
liveKitRoom.on(RoomEvent.Disconnected, (reason) => console.log('Disconnected:', reason));

await liveKitRoom.connect(broadcastData.coHostUrl, broadcastData.coHostToken);
await liveKitRoom.localParticipant.setCameraEnabled(true);
await liveKitRoom.localParticipant.setMicrophoneEnabled(true);
// Room status is now LIVE
```

Full reference → [Start Broadcasting](/social-plus-sdk/video-new/broadcasting/start-broadcasting.md)

**4. Monitor room lifecycle**

Observe the room to update your UI for each status transition.

```typescript theme={null}
const roomLiveObject = RoomRepository.getRoom(room.roomId);

roomLiveObject.on('dataUpdated', (room) => {
  switch (room.status) {
    case 'idle':     showUI('Ready to start'); break;
    case 'live':     showUI('Broadcasting'); break;
    case 'ended':    showUI('Stream ended — processing recording…'); break;
    case 'recorded': showUI('Recording available'); break;
  }
});
```

Full reference → [Manage Rooms](/social-plus-sdk/video-new/broadcasting/manage-rooms.md)

**5. Query live rooms for a 'Live Now' section**

Show currently-active livestreams in your app.

```typescript theme={null}
const liveRooms = RoomRepository.getRooms({
  statuses: ['live'],
  types: ['co_hosts'],
  isDeleted: false,
  sortBy: 'lastCreated',
});

liveRooms.on('dataUpdated', (rooms) => {
  console.log('Currently live:', rooms.length, 'rooms');
});
```

Full reference → [Manage Rooms](/social-plus-sdk/video-new/broadcasting/manage-rooms.md)

**6. Stop broadcasting and access recordings**

Disconnect LiveKit first, then stop the room. Recordings become available within a few minutes.

```typescript theme={null}
// 1. Disconnect from LiveKit
await liveKitRoom.disconnect();

// 2. Stop the room
await RoomRepository.stopRoom(room.roomId);

// 3. Poll for recording (room status transitions: ENDED → RECORDED)
const { url } = await RoomRepository.getRecordedUrl(room.roomId);
console.log('Recording:', url);
```

Full reference → [Recorded Playback](/social-plus-sdk/video-new/broadcasting/recorded-playback.md)

***

## Admin Console: Manage & Monitor Streams

After streams are created, you can manage them from **Admin Console → Live stream**.

![Admin Console live stream management table showing stream titles, types, broadcast status, and moderation results](https://mintcdn.com/social-b97141fb-auto-generate-llmstxt/HK8-O4u_NqMeCf6h/images/analytics-and-moderation/console-live-stream-management.png?fit=max\&auto=format\&n=HK8-O4u_NqMeCf6h\&q=85\&s=1139e108cd8f710947aa6a607c802e9d)

Live stream management — view all streams with status, type, and moderation flags

Click any stream to see its detail page with recording playback, metadata, and moderation status.

![Admin Console stream detail page showing video player, stream ID, feed details, and moderation labels](https://mintcdn.com/social-b97141fb-auto-generate-llmstxt/HK8-O4u_NqMeCf6h/images/analytics-and-moderation/console-live-stream-detail.png?fit=max\&auto=format\&n=HK8-O4u_NqMeCf6h\&q=85\&s=d6180692235eac148ba090dc6f3d5ca9)

Stream detail — recording playback, stream ID, creator info, and moderation status

To review stream performance, go to **Admin Console → Video Analytics → Live stream**.

![Admin Console livestream analytics showing total streams created, views, unique viewers, and minutes watched](https://mintcdn.com/social-b97141fb-auto-generate-llmstxt/HK8-O4u_NqMeCf6h/images/dashboard-livestream-analytics.png?fit=max\&auto=format\&n=HK8-O4u_NqMeCf6h\&q=85\&s=1694787c1ef071b74f4a53d7abdf3356)

Livestream analytics dashboard — total streams, views, unique viewers, and watch time

Click any row in the stream table to see per-stream metrics including concurrent viewers over time and chat messages.

![Admin Console individual stream analytics showing viewer timeline, chat message count, and reaction count](https://mintcdn.com/social-b97141fb-auto-generate-llmstxt/HK8-O4u_NqMeCf6h/images/dashboard-livestream-detail.png?fit=max\&auto=format\&n=HK8-O4u_NqMeCf6h\&q=85\&s=3625d38ea299ced84e687afd21feb505)

Per-stream analytics — unique viewers, chat messages, and reactions over time

***

## Connect to Moderation & Analytics

> [accordion] Stream analytics in Admin Console
>
> Track peak concurrent viewers, total watch time, and engagement per stream in **Admin Console → Analytics → Video**.
>
> → [Video Analytics](/social-plus-sdk/video-new/analytics/overview.md)

> [accordion] Livestream moderation
>
> Moderators can view and manage all active and past livestreams in **Admin Console → Moderation → Livestream Moderation**.
>
> → [Livestream Moderation](/analytics-and-moderation/console/moderation/livestream-moderation.md)

> [accordion] Webhook: stream lifecycle events
>
> Receive `stream.started`, `stream.ended`, `recording.completed` webhook events for backend automation (e.g., notify followers, archive recordings).
>
> → [Stream Events](/social-plus-sdk/video-new/broadcasting/overview.md) · [Webhooks](/analytics-and-moderation/social+-apis-and-services/webhook-event.md)

***

## Common Mistakes

> [!WARNING]
>
> **Stopping the room before disconnecting LiveKit** — Always call `liveKitRoom.disconnect()` first, then `RoomRepository.stop(roomId)`. Reversing the order can leave orphaned media tracks.

> [!WARNING]
>
> **Forgetting to end rooms when the stream stops** — If the broadcaster disconnects without calling `stop()`, the room stays in `live` status and appears in "Live Now" feeds as a ghost stream. Always call stop in your cleanup logic.
>
> ```typescript theme={null}
> // ❌ Bad — broadcaster crashes, room stays live
> window.onbeforeunload = () => { /* nothing */ };
>
> // ✅ Good — end room on disconnect
> window.onbeforeunload = () => {
>   RoomRepository.stopRoom(roomId);
> };
> ```

> [!WARNING]
>
> **Not refreshing the LiveKit token** — LiveKit tokens expire. If you don't handle token refresh, the video connection drops mid-stream. Implement a token renewal callback.

> [!WARNING]
>
> **Creating rooms without `channelEnabled: true`** — Without this flag, no live chat channel is created and viewers can't comment during the stream. Almost all livestream UIs need live chat.

> [!WARNING]
>
> **Not observing the room lifecycle** — The status transitions (`idle → live → ended → recorded`) are asynchronous. Hardcoding delays instead of observing the room live object results in brittle UI states.

> [!WARNING]
>
> **Polling for recordings too aggressively** — Recordings take a few minutes to process. Use the room's live object with a `dataUpdated` listener to detect when `status === 'recorded'` rather than polling every second.

## Best Practices

> [accordion] Startup latency
>
> * Pre-fetch `getBroadcastData()` before the user taps "Go Live" to cut startup time
> * Request camera and microphone permissions during the room creation step, not at connect time
> * Show a preview of the camera feed while the LiveKit connection is establishing

> [accordion] Reconnection handling
>
> * Listen for `RoomEvent.Reconnecting` and `RoomEvent.Reconnected` from LiveKit
> * Show a "Reconnecting…" banner to the host — don't silently drop to ended
> * Configure LiveKit's `autoSubscribe` and `reconnectPolicy` for aggressive retry

> [accordion] Broadcasting UX
>
> * Show a 3-second countdown before going live so the broadcaster can prepare
> * Display a "LIVE" badge with a pulsing animation on the post card in the feed
> * Show concurrent viewer count in real-time using the room's participant data
> * Provide camera flip, mute, and end-stream controls in a floating overlay

> [accordion] Viewer experience
>
> * Auto-play the livestream on mute when the post enters the viewport — require a tap for audio
> * Show the live chat alongside the video in a split-screen layout
> * Allow viewers to send reactions (emoji) that float across the video
> * When the stream ends, show a "Stream ended" card with a link to the recording when available

> [accordion] Recordings
>
> * The livestream post stays in the feed after the stream ends — update it to show the recording thumbnail
> * Store recording URLs in your backend; platform URLs may have retention policies
> * Offer a "Watch replay" CTA on the post once `status === 'recorded'`

***

## Next Steps

> [card] [Your next step → Short-Form Video Clips](/use-cases/social/short-form-video-clips.md)
>
> Livestreams are running — now add TikTok-style clip posts for shorter, snackable video content.

Or explore related guides:

> [card] [Co-Hosting](/use-cases/social/livestream/co-hosting.md)
>
> Invite co-hosts to share the stage during a broadcast.

> [card] [Live Chat & Engagement](/use-cases/social/livestream/live-chat-and-engagement.md)
>
> Wire up chat, reactions, and viewer count alongside the video.

> [card] [Product Tagging](/use-cases/social/livestream/product-tagging.md)
>
> Pin products to the stream for live commerce.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.