Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-twilio-video`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/twilio-video/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
Section titled “Install”You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-twilio-video` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
npm install @capgo/capacitor-twilio-videonpx cap syncImport
Section titled “Import”import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';iOS setup
Section titled “iOS setup”1. Install the plugin
Section titled “1. Install the plugin”npm install @capgo/capacitor-twilio-videonpx cap sync ios2. Twilio Video SDK floor
Section titled “2. Twilio Video SDK floor”This plugin links twilio-video-ios through Swift Package Manager with a floor of 5.11.3 (from: "5.11.3" in Package.swift). The CocoaPods dependency is TwilioVideo ~> 5.11, which allows any 5.11.x release and can resolve below 5.11.3 if a lockfile already pinned an older patch. New installs typically get the latest 5.11.x.
Minimum iOS deployment target: 15.0.
3. Setup Info.plist
Section titled “3. Setup Info.plist”Add the following to ios/App/App/Info.plist:
<key>NSMicrophoneUsageDescription</key><string>This app uses the microphone for video calls</string><key>NSCameraUsageDescription</key><string>This app uses the camera for video calls</string>The plugin configures AVAudioSession for videoChat when you join a room and shows a native in-app call overlay above the WebView.
Run npx cap sync ios after install so Swift Package Manager or CocoaPods picks up CapgoCapacitorTwilioVideo.
Android setup
Section titled “Android setup”1. Install the plugin
Section titled “1. Install the plugin”npm install @capgo/capacitor-twilio-videonpx cap sync android2. Twilio Video SDK floor
Section titled “2. Twilio Video SDK floor”The plugin depends on com.twilio:video-android:7.10.5. Gradle sync pulls it from Maven Central.
Minimum minSdkVersion: 24.
3. Permissions
Section titled “3. Permissions”The plugin registers Capacitor permission aliases for RECORD_AUDIO and CAMERA. Request them before joining with audio or video:
await CapacitorTwilioVideo.requestMicrophonePermission();await CapacitorTwilioVideo.requestCameraPermission();If your host app does not inherit the plugin manifest merger entries, declare the permissions in android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.CAMERA" />Twilio setup
Section titled “Twilio setup”Generate short-lived Video access tokens on your backend. Never mint Twilio access tokens inside the mobile app, and never ship your Twilio API secret in the app. See Twilio’s guides:
Tokens use JWT format with a grants object. Example:
{ "iss": "your-api-key-sid", "sub": "your-account-sid", "exp": 1234567890, "grants": { "identity": "user-identity", "video": { "room": "daily-standup" } }}iss is the signing API Key SID (SK...). sub is the Account SID (AC...).
The plugin validates expiration before login() and joinRoom(). Invalid or expired tokens are rejected on the native layer.
Connect, join, and tracks
Section titled “Connect, join, and tracks”Mint a Twilio Video access token on your server, then log in and join a room. Defaults for joinRoom are enableAudio: true and enableVideo: false.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const token = await fetchVideoTokenFromYourBackend();
await CapacitorTwilioVideo.requestMicrophonePermission();await CapacitorTwilioVideo.requestCameraPermission();
await CapacitorTwilioVideo.login({ accessToken: token });
await CapacitorTwilioVideo.addListener('roomConnected', ({ roomName, participantCount }) => { console.log('Connected', roomName, participantCount);});
await CapacitorTwilioVideo.addListener('participantConnected', ({ identity, participantCount }) => { console.log('Participant joined', identity, participantCount);});
await CapacitorTwilioVideo.joinRoom({ roomName: 'daily-standup', enableAudio: true, enableVideo: true,});
const status = await CapacitorTwilioVideo.getCallStatus();console.log(status.callState, status.isMicrophoneEnabled, status.isCameraEnabled);
await CapacitorTwilioVideo.setMicrophoneEnabled({ enabled: false });await CapacitorTwilioVideo.setCameraEnabled({ enabled: true });
await CapacitorTwilioVideo.leaveRoom();await CapacitorTwilioVideo.logout();Event listeners
Section titled “Event listeners”import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
await CapacitorTwilioVideo.addListener('roomDisconnected', (data) => { console.log('Room left', data);});
await CapacitorTwilioVideo.addListener('roomReconnecting', (data) => { console.log('Reconnecting', data);});
await CapacitorTwilioVideo.addListener('roomReconnected', (data) => { console.log('Reconnected', data);});addListener returns a handle. Call handle.remove() when the screen unmounts, or CapacitorTwilioVideo.removeAllListeners() to clear every listener.
Common pitfalls
Section titled “Common pitfalls”- Tokens: never mint Twilio access tokens inside the mobile app. Generate them on your backend with a short TTL.
- Permissions: call
requestMicrophonePermissionandrequestCameraPermissionbeforejoinRoomwhen the matching media is enabled. - Single room:
joinRoomrejects when a room is already active. CallleaveRoomfirst. - Web: the web implementation is intentionally unimplemented. Use Twilio’s JavaScript SDK for browser clients.
- Reconnection: listen for
roomReconnectingandroomReconnectedto update your UI during network changes.
API overview
Section titled “API overview”Store and validate a Twilio Video access token minted by your backend. Expired tokens are rejected.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.login({ accessToken: 'access-token-123' });console.log(result);logout
Section titled “logout”Clear the cached access token, leave any active room, and tear down the native call UI.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.logout();console.log(result);isLoggedIn
Section titled “isLoggedIn”Check whether a valid Twilio token is currently cached on the device. Returns { isLoggedIn, hasValidToken, identity? }. The optional identity field comes from the token grants.identity claim.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.isLoggedIn();if (result.isLoggedIn && result.hasValidToken) { console.log('User identity:', result.identity);}joinRoom
Section titled “joinRoom”Join a Twilio room and present the plugin’s native in-app call overlay. Local audio and video tracks publish when enabled. Defaults: enableAudio: true, enableVideo: false.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.joinRoom({ roomName: 'daily-standup', enableAudio: true, enableVideo: true,});console.log(result);leaveRoom
Section titled “leaveRoom”Leave the current room if connected.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.leaveRoom();console.log(result);setMicrophoneEnabled
Section titled “setMicrophoneEnabled”Publish or unpublish the local microphone track while in a room.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.setMicrophoneEnabled({ enabled: true });console.log(result);setCameraEnabled
Section titled “setCameraEnabled”Publish or unpublish the local camera track while in a room.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.setCameraEnabled({ enabled: true });console.log(result);getCallStatus
Section titled “getCallStatus”Return the current room name, callState, remote participant count, and local mic or camera enabled flags. callState is 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'disconnected'.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const status = await CapacitorTwilioVideo.getCallStatus();console.log(status.callState, status.participantCount);checkMicrophonePermission
Section titled “checkMicrophonePermission”Check microphone permission state.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.checkMicrophonePermission();console.log(result);requestMicrophonePermission
Section titled “requestMicrophonePermission”Request microphone permission.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.requestMicrophonePermission();console.log(result);checkCameraPermission
Section titled “checkCameraPermission”Check camera permission state.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.checkCameraPermission();console.log(result);requestCameraPermission
Section titled “requestCameraPermission”Request camera permission.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.requestCameraPermission();console.log(result);addListener
Section titled “addListener”Listen for room and participant lifecycle events: roomConnected, roomDisconnected, participantConnected, participantDisconnected, roomReconnecting, and roomReconnected.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const handle = await CapacitorTwilioVideo.addListener('roomConnected', ({ roomName, participantCount }) => { console.log('Connected to', roomName, 'participants', participantCount);});removeAllListeners
Section titled “removeAllListeners”Remove every listener registered through this plugin instance.
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
await CapacitorTwilioVideo.removeAllListeners();Source of truth
Section titled “Source of truth”This page is synced from the plugin’s src/definitions.ts and README in capacitor-twilio-video. Re-run the sync when the public API changes upstream.
Keep going from Getting Started
Section titled “Keep going from Getting Started”If you are using Getting Started to plan native media and interface behavior, connect it with Using @capgo/capacitor-twilio-video for the native capability in Using @capgo/capacitor-twilio-video, Using @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities for the implementation detail in @capgo/capacitor-live-activities, Using @capgo/capacitor-video-player for the native capability in Using @capgo/capacitor-video-player, and @capgo/capacitor-video-player for the implementation detail in @capgo/capacitor-video-player.