What LiveKit provides
- Room management: named rooms that participants join using short-lived tokens
- Participant tokens: JWT-based credentials scoped to a specific room and identity
- SFU architecture: a single media server receives each participant’s stream and forwards it selectively, avoiding the O(n²) bandwidth cost of a pure mesh
- Cross-platform SDKs: consistent APIs for web (React), iOS, and Android
How HashDrop uses LiveKit
HashDrop integrates LiveKit at three layers:Server-side: Next.js API routes
Thelivekit-server-sdk is used inside Next.js API routes to generate participant tokens and manage room state. No media passes through these routes — they only handle control plane operations.
Web frontend: React components
The@livekit/components-react package provides pre-built React components (<LiveKitRoom>, <VideoConference>, participant tiles) that connect directly to the LiveKit server. The useConferenceLogic hook attaches to RoomEvent listeners for connected, disconnected, participant joined/left, and data channel messages (chat, file transfer, join requests).
Mobile app: React Native SDK
The@livekit/react-native package mirrors the web SDK’s API for Expo-based iOS and Android builds, providing the same room connection and media publishing capabilities with native camera and microphone handling.
Conference API endpoints
HashDrop’s Next.js backend exposes six conference API routes:| Method | Path | Description |
|---|---|---|
POST | /api/conference/create | Create a new LiveKit room and return a host token. |
POST | /api/conference/join | Generate a participant token for an existing room. |
POST | /api/conference/generate-code | Generate a shareable conference code for the room. |
POST | /api/conference/admit | Grant publish permissions to a participant in the waiting room. |
POST | /api/conference/deny | Remove a waiting participant from the room. |
GET | /api/conference/waiting | Return the list of participants currently in the waiting room. |
Room lifecycle
- Create: the host calls
/api/conference/create, receiving a room name and a host token. The host’s client connects to LiveKit with full publish permissions and immediately starts the call. - Share code:
/api/conference/generate-codeproduces a human-readable code that other participants use to find the room. - Join: participants call
/api/conference/joinwith the conference code. If a waiting room is configured, their token is issued withcanPublish: false. - Waiting room: participants in the waiting room send a
join-requestdata message to the host every 5 seconds. The host polls/api/conference/waitingevery 2 seconds as a fallback in case the data message is missed. - Admit or deny: the host calls
/api/conference/admit(which updates LiveKit permissions to allow publishing) or/api/conference/deny(which removes the participant). The admitted participant detects the permission change viaParticipantEvent.ParticipantPermissionsChangedand begins publishing camera and microphone tracks. - End: when the host disconnects or the room is deleted, remaining participants receive
DisconnectReason.ROOM_DELETEDand are returned to the lobby.
Connecting to a LiveKit server requires
LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET environment variables to be set in your deployment. Without these, token generation will fail and video conferences cannot be started. See Environment variables for the full list of required configuration.Environment variables
Configure LiveKit server credentials and other required environment variables.