Skip to content

Getting Started

GitHub

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

Terminal window
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Then 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:

Terminal window
npm install @capgo/capacitor-twilio-video
npx cap sync
import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
Terminal window
npm install @capgo/capacitor-twilio-video
npx cap sync ios

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.

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.

Terminal window
npm install @capgo/capacitor-twilio-video
npx cap sync android

The plugin depends on com.twilio:video-android:7.10.5. Gradle sync pulls it from Maven Central.

Minimum minSdkVersion: 24.

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" />

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.

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();
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.

  • Tokens: never mint Twilio access tokens inside the mobile app. Generate them on your backend with a short TTL.
  • Permissions: call requestMicrophonePermission and requestCameraPermission before joinRoom when the matching media is enabled.
  • Single room: joinRoom rejects when a room is already active. Call leaveRoom first.
  • Web: the web implementation is intentionally unimplemented. Use Twilio’s JavaScript SDK for browser clients.
  • Reconnection: listen for roomReconnecting and roomReconnected to update your UI during network changes.

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);

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);

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);
}

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);

Leave the current room if connected.

import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.leaveRoom();
console.log(result);

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);

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);

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);

Check microphone permission state.

import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.checkMicrophonePermission();
console.log(result);

Request microphone permission.

import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.requestMicrophonePermission();
console.log(result);

Check camera permission state.

import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.checkCameraPermission();
console.log(result);

Request camera permission.

import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
const result = await CapacitorTwilioVideo.requestCameraPermission();
console.log(result);

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);
});

Remove every listener registered through this plugin instance.

import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
await CapacitorTwilioVideo.removeAllListeners();

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.

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.