Skip to main content

React Native SDK quick integration

The current npm package is react-native-meshstream 1.0.5, published on npm. It provides a shared JavaScript client/session API while the application continues to own the player.

Before running the code, complete Installation and setup, prepare your SDK Key and playable media URL, and configure the application network policy.

Minimal integration​

import Video from 'react-native-video';
import { MeshStream } from 'react-native-meshstream';

const client = await MeshStream.create({ key: 'your_sdk_key' });
const session = await client.createPlaybackSession({
url: 'https://cdn.example.com/live/playlist.m3u8',
contentId: 'live-channel-42',
mimeType: 'm3u8',
});

<Video source={{ uri: session.playbackUrl }} controls />;

Close the active resources when the player is destroyed or the content changes:

await session.close();
await client.close();

When P2P policy, Tracker, or peers are unavailable, playback falls back to CDN. Use getStatus(), getStats(), getDiagnostics(), and addMeshStreamEventListener for diagnostics; do not stop the player because acceleration is unavailable.

Preload and multiple players​

A client can manage multiple independent sessions. Create a session for the next item and call await next.preload(); pass next.playbackUrl to the player only when that item starts. Close discarded candidates.

Version and verification​

The React Native package version is independent of the native SDK versions. Record both versions in diagnostics. See the React Native SDK repository for the example and release records.

Related guides: Installation and setup · Advanced usage.