Quickstart
Broadcast and view your first livestream
In this tutorial you install the Native Frame client and build two small apps: a broadcaster that streams your camera, and a viewer that watches it. By the end you will have a livestream playing in your own page. Set your framework once in the sidebar — the samples in every step follow it, and the three steps are the same either way.
Prerequisites
Before you start, you need a Native Frame account and three values from it:
| Credential | What it looks like | From |
|---|---|---|
| Authentication token (JWT) | A signed token string. | Generate an API token |
| Stream key | Identifies the stream you publish to. | Get your RTMP URL and stream key |
| Backend endpoint | https://your-subdomain.nativeframe.com | Copy your backend endpoint |
If you do not have these yet, follow Create an account and get credentials first, then come back here.
You do not need any of this to watch a stream play. Create an account and get credentials opens with a no-code path: create a stream in the dashboard, publish to it from software like OBS, and play it back — no token, no install. Come here when you want to build it into your own app.
You paste those values in by hand below, which is fine for a local run. Before you ship anything, read Token setup: in production your backend mints a short-lived token per session instead.
Instead of pasting values in, fetch backendEndpoints, streamKey, and the token from your own endpoint when the page loads. Configure from your server shows the request, the validation, and which values are safe in the browser.
Steps
Step 1: Install the client
Install the Native Frame client if you have not already — Installation covers npm, yarn, and the CDN, and is the one place install is taught:
npm install @video/video-client-react
Building the vanilla JavaScript version instead? Installation's CDN tab has the import map to use; there is nothing to install for that path.
Step 2: Build your first broadcaster
Create a broadcaster that streams your camera to viewers. In order, the code below authenticates with your token, initialises the camera and shows a local preview, configures the call with your stream key and backend endpoint, and wires up the start and stop controls.
The token literals in the code below are for a local tutorial run only. Anything you put in front-end JavaScript is readable by anyone who loads the page. In production your backend mints a short-lived token per session — see Token setup.
<!DOCTYPE html>
<html>
<head>
<script type="importmap">
{
"imports": {
"vdc-cdn": "https://cdn.nativeframe.com/video-client-core/14.0.0/index.js"
}
}
</script>
</head>
<body>
<div id="preview"></div>
<button id="startBtn">Start Broadcasting</button>
<button id="stopBtn" style="display:none">Stop Broadcasting</button>
<script type="module">
import {
createCall,
BaseAuthClient,
mediaController,
requestPlayer
} from 'vdc-cdn';
let call, broadcast;
// Set up authentication
const authClient = new BaseAuthClient('your-broadcaster-token');
// Initialize camera
await mediaController.init();
const mediaStreamController = await mediaController.requestController();
// Create preview
const previewPlayer = await requestPlayer({
mediaStreamController,
muted: true
});
const video = document.createElement('video');
document.getElementById('preview').appendChild(video);
previewPlayer.attach(video);
// Start broadcast
document.getElementById('startBtn').onclick = async () => {
call = await createCall({
streamKey: 'your-stream-key',
backendEndpoints: ['https://your-subdomain.nativeframe.com'],
auth: authClient,
user: { userId: 'user-1', displayName: 'Broadcaster' }
});
// This is the value your viewer needs in Step 3. Copy it from the console.
console.log('Call ID:', call.id);
broadcast = await call.broadcast(mediaStreamController, {
streamName: 'default'
});
document.getElementById('startBtn').style.display = 'none';
document.getElementById('stopBtn').style.display = 'block';
};
// Stop broadcast
document.getElementById('stopBtn').onclick = async () => {
await broadcast?.dispose();
await call?.dispose();
document.getElementById('startBtn').style.display = 'block';
document.getElementById('stopBtn').style.display = 'none';
};
</script>
</body>
</html>
You now have a broadcaster with a camera preview and start/stop controls.
Step 3: Build your first viewer
Create a viewer that plays the broadcast. The viewer connects by call ID — the ID of the call your broadcaster created in Step 2 — so get that value first. The React and vanilla JavaScript tabs take the same one; the React Native tab takes a manifest URL instead, and says so.
Verify the loop end to end (React and vanilla JavaScript): run your broadcaster, take the call ID it gives you (the React version
renders it on the page, the vanilla version logs it to the console), and pass it to the viewer as
callId. When the viewer shows your camera, the broadcast-to-playback loop works. React Native has its own
verify step in its tab below.
import React, { useState } from 'react';
import { useAuthClient } from '@video/video-client-react/hooks';
import { PlayerAPIProvider } from '@video/video-client-react/context';
import { Video } from '@video/video-client-react/components';
import { createPlayer } from '@video/video-client-react';
function Viewer({ callId }) {
const [player, setPlayer] = useState(null);
const authClient = useAuthClient('your-viewer-token');
React.useEffect(() => {
let created;
let cancelled = false;
createPlayer({
callId: callId,
streamName: 'default',
backendEndpoints: ['https://your-subdomain.nativeframe.com'],
auth: authClient
}).then((next) => {
created = next;
// If the component unmounted while createPlayer was still resolving,
// dispose immediately rather than storing a player nobody will clean up.
if (cancelled) next.dispose();
else setPlayer(next);
});
return () => {
cancelled = true;
created?.dispose();
};
}, [callId, authClient]);
if (!player) return <div>Loading stream...</div>;
return (
<PlayerAPIProvider player={player}>
<div>
<h1>Watching Livestream</h1>
<Video />
</div>
</PlayerAPIProvider>
);
}
export default Viewer;
// Render it with the call ID your broadcaster printed on the page in Step 2.
// Hard-coding it is fine while you are following this guide; in a real app the
// broadcaster would hand this to the viewer over your own backend.
//
// <Viewer callId="call-id-from-broadcaster" />
<!DOCTYPE html>
<html>
<head>
<script type="importmap">
{
"imports": {
"vdc-cdn": "https://cdn.nativeframe.com/video-client-core/14.0.0/index.js"
}
}
</script>
</head>
<body>
<div id="player"></div>
<script type="module">
import { createPlayer, BaseAuthClient } from 'vdc-cdn';
const authClient = new BaseAuthClient('your-viewer-token');
const player = await createPlayer({
callId: 'call-id-from-broadcaster',
streamName: 'default',
backendEndpoints: ['https://your-subdomain.nativeframe.com'],
auth: authClient
});
const video = document.createElement('video');
video.controls = true;
document.getElementById('player').appendChild(video);
player.attach(video);
</script>
</body>
</html>
The React Native SDK plays a manifest URL, not a call ID, so the viewer in this step takes the manifestUrl from the stream-detail response instead of the callId the web tabs use. To get it, start your broadcaster, then call the stream detail endpoint (GET /program/api/v2/streams/{id}) for the stream it published (the one with streamName: 'quickstart') and read manifestUrl from the response. Pass it through verbatim; see Manifests.
Verify the loop end to end (React Native): with the broadcaster live, fetch manifestUrl as above and pass it to Viewer.
import React from 'react';
import { View } from 'react-native';
import { VideoPlayer, getSession } from '@video/react-native-sdk';
export default function Viewer({ manifestUrl }: { manifestUrl: string }) {
const session = getSession({
backendEndpoint: 'https://your-subdomain.nativeframe.com',
displayName: 'Quickstart viewer',
streamName: 'quickstart',
});
return (
<View style={{ flex: 1 }}>
<VideoPlayer
manifestUrl={manifestUrl}
session={session}
autoplay
style={{ width: '100%', height: 200 }}
onError={(error) => console.error('Video error:', error)}
/>
</View>
);
}
// Render it with the manifest URL of the stream your broadcaster publishes:
//
// <Viewer manifestUrl="https://…/<streamId>.json" />
VideoPlayer plays HLS only. When you need WebRTC playback with HLS fallback, use ManifestPlayer with its ManifestPlayerVideo render prop instead; the React Native tab of View a Stream shows both. When the viewer shows your camera, the broadcast-to-playback loop works.
Open the broadcaster and click Start Broadcasting, then load the viewer with that callId. Your camera
should appear in the viewer's player.
Next steps
Now that the basics work, go deeper: