1. Include the SDK
For Browsers:
<script src="https://cdn.jsdelivr.net/gh/steveseguin/ninjasdk@latest/vdoninja-sdk.min.js"></script>
For Node.js:
npm install @vdoninja/sdk @roamhq/wrtc
# Then in your code:
const VDONinjaSDK = require('@vdoninja/sdk/node');
See README-NODE.md for detailed Node.js setup instructions.
2. Basic Data Channel Example
// Create a new VDO.Ninja SDK instance
const vdo = new VDONinjaSDK();
// Set up data channel handling
vdo.addEventListener('dataReceived', (event) => {
const { data, uuid } = event.detail;
console.log(`Received from ${uuid}:`, data);
});
// Run in two tabs with the same private room name.
// Wait for a peer's data channel before sending.
vdo.addEventListener('dataChannelOpen', () => {
vdo.sendData({ message: "Hello from this peer!" });
});
await vdo.autoConnect({ room: "replace_with_your_unique_room" });
Connection guide: complete examples and troubleshooting
3. Audio/Video Example
// Create instance for audio/video
const vdo = new VDONinjaSDK({ salt: "vdo.ninja", host: "wss://apibackup.vdo.ninja" });
// Set up track handling
vdo.addEventListener('track', (event) => {
const { track, streams, uuid } = event.detail;
const video = document.getElementById('remoteVideo');
if (!video.srcObject) {
video.srcObject = new MediaStream();
}
video.srcObject.addTrack(track);
});
// Get user media
const stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
});
// Connect, join room, and publish
await vdo.connect();
await vdo.joinRoom({ room: "videoroom" });
await vdo.publish(stream, { streamID: "my_camera" });
// Viewer: https://vdo.ninja/alpha/?view=my_camera&room=videoroom&scene&wss2=apibackup.vdo.ninja
๐ฌ Social Stream Ninja Integration
Two-way live chat with all major social media platforms in one unified stream
๐ Supported Platforms
๐ Simple Integration
๐ Use Cases