Key Features
- Native video playback: on-demand, adaptive streaming, captions, and controls configured through the Bunny Stream dashboard.
- Resumable uploads: TUS transfers with progress events, pause, resume, cancellation, and interrupted-transfer recovery.
- Camera publishing: record new videos and upload videos directly from the device camera
- Typed content management: videos, collections, captions, encoding, transcription, and statistics, with operation-specific platform support.
- Platform playback features: Picture-in-Picture, AirPlay on iOS, Chromecast on Android, FairPlay/Widevine-protected playback, and an optional Android TV player integration.
- Expo integration: a config plugin for native setup and TypeScript APIs shared with bare React Native applications.
What is the Bunny Stream React Native SDK?
The SDK is an npm package wrapping the official Android SDK and iOS SDK. React components render native player and camera views; hooks and typed events connect those views to your application state. It does not render the web player in a WebView, and it does not support Expo Go or web. Native capabilities are not necessarily exposed as equivalent JavaScript APIs on both platforms. Check the platform notes in the playback, content management, upload, and broadcasting guides for operation-specific support.React Native SDK
Requirements
- React Native with the New Architecture enabled.
- Android API 26+,
compileSdk36+, JDK 17, Kotlin 2.2.20+, and core library desugaring. - iOS deployment target compatible with your React Native version, Xcode, and CocoaPods with React Native’s
spm_dependencysupport. The native Bunny iOS SDK requires iOS 15+. - Expo SDK 52+ if using Expo, with a native development build.
- A Bunny Stream video library and an initialization/credential flow appropriate for your app.
Installation
The plugin supplies default iOS camera/microphone permission messages. Customize them with
cameraPermission and microphonePermission when needed, and request runtime permissions before opening the camera. Rebuild the native application after configuration changes.Initialize and play
Before mounting a player or using the management/upload APIs, callinitialize(accessKey, libraryId) once during application startup. It validates configuration synchronously; keep SDK content unmounted if initialization fails.
After initialization, render a VOD player:
For VOD,
libraryId falls back to the library passed to initialize(); provide it explicitly to override that ID. This fallback does not apply to management calls, uploads, or broadcaster sources.Token authentication
Protected playback involves two layers:- Embed View Token Authentication authorizes access to a video. Your backend or Edge Script verifies the user’s entitlement and returns a token and expiry.
- CDN Token Authentication protects delivery from Bunny CDN and is handled by the native SDK using the playback configuration when enabled for the library.
Embed View Token Authentication
The React Native SDK forwards authorization to the native player. It does not authenticate your users or decide which videos they are allowed to watch. React Native SDK responsibility- The customer backend generates the token after authorizing the user.
- The app requests the token and passes it to
BunnyStreamPlayerthroughsource. - The native SDK handles playback and the configured CDN delivery protection.
Supported authentication methods
Backend requirements
Your backend or Edge Script must:- Keep the playback-token signing secret on the server.
- Authenticate the requesting user and check access to the requested video.
- Generate a token for that specific media ID using the Stream token-signing procedure.
- Return
{ token, expires }over HTTPS, with expiry expressed as Unix seconds.
Use short-lived tokens appropriate for the playback flow; 1–5 minutes is a useful starting point.
React Native usage
After initialization and a successful authorization response from your backend, pass the token and expiry throughsource:
generateEmbedToken and signPlaybackToken methods on BunnyStreamApi are demo/debug conveniences, not a production client-side signing flow. See Secure playback for credential boundaries, protected images, and DRM notes.
Flow
1
Request the embed token
Call your authenticated backend or Edge Script for the target video or stream ID. The backend checks the user’s access before generating a token.
2
Receive the token
Your backend returns
{ token, expires }, with expiry expressed as Unix seconds.3
Play the video
After SDK initialization, pass
token and expires through the player’s source.Uploads and background behavior
Choosemode: 'tus' explicitly when starting a resumable upload; startUpload defaults to basic. Subscribe to upload events before starting transfers and retain the video/file details needed for recovery. Transfer completion does not mean encoding has finished.
Android uploads stop with the process; TUS can continue after relaunch with saved details. iOS TUS supports background URLSession transfers and cached recovery, but user force-quit is different from system termination and recovery depends on available files and valid authorization.