Migrating from v6 to v7
Version 7 of React Native Video introduces a significant architectural shift, separating the video player logic from UI rendering. This change unlocks new capabilities like video preloading, better performance, and a more intuitive hook-based API.What’s New in v7
Nitro Modules Architecture
v7 is built on top ofreact-native-nitro-modules, a modern framework that provides:
- Type-safety: Full TypeScript support with native type checking
- Performance: Blazing fast communication between Native and JavaScript threads
- Modern Architecture: Full support for React Native’s New Architecture
- Better Developer Experience: Improved error handling and debugging
Component Separation
The monolithic<Video> component is now split into:
VideoPlayer: A class that manages player state and playback logic (not a UI component)VideoView: A UI component that renders the video on screenuseVideoPlayerhook: Recommended way to create and manageVideoPlayerlifecycleuseEventhook: Standardized event handling with automatic cleanup
Key Benefits
- Video Preloading: Create player instances before displaying them
- Better Performance: Separation of concerns improves rendering efficiency
- Cleaner API: Hook-based API reduces boilerplate code
- Multiple Players: Easier management of multiple video players
- Picture-in-Picture: Enhanced PiP support for multiple videos
Requirements
System Requirements
- iOS 15.0 or higher
- Android 6.0 or higher
Package Requirements
- React Native 0.75.0 or higher
react-native-nitro-modules0.27.2 or higher (recommended 0.31.10+)
Migration Steps
Install New Dependencies
First, install the new dependencies. Note that v7 requires For iOS, install pods:
react-native-nitro-modules:Replace Component Structure
Replace the v7 Example:
<Video> component with useVideoPlayer hook and <VideoView> component.v6 Example:Migrate Props
Move props to their new locations. Some props stay on
<VideoView>, while others move to the VideoPlayer configuration.Props on VideoView (UI-related)
stylecontrolsresizeMode
Props on VideoPlayer (Playback-related)
All playback-related props are now configured inuseVideoPlayer or set directly on the player instance:sourcepausedmutedvolumerateloop- And more…
Update Method Calls
Methods previously called on the component ref are now on the v7:
VideoPlayer instance.v6:Fullscreen methods are now on the
VideoView ref, not the player instance.Migrate Event Handlers
Event handling is now standardized through the Direct Assignment:See the Events documentation for all available events.
useEvent hook or direct callback assignment.Using useEvent (Recommended):Breaking Changes Reference
Component Changes
| v6 | v7 | Notes |
|---|---|---|
<Video /> | <VideoView player={player} /> | Complete redesign |
ref={videoRef} | Separate: player for playback, ref for VideoView | Fullscreen methods on VideoView ref |
Props Migration
v6 Prop (<Video>) | v7 Equivalent | Location |
|---|---|---|
source | source | useVideoPlayer config |
paused | paused | Player property or config |
muted | muted | Player property or config |
volume | volume | Player property or config |
rate | rate | Player property or config |
loop | loop | Player property or config |
resizeMode | resizeMode | <VideoView> prop |
controls | controls | <VideoView> prop |
Methods Migration
| v6 Method | v7 Method | Location |
|---|---|---|
videoRef.current.seek(time) | player.seekTo(time) | Player instance |
videoRef.current.pause() | player.pause() | Player instance |
videoRef.current.resume() | player.play() | Player instance |
videoRef.current.presentFullscreenPlayer() | videoViewRef.current.enterFullscreen() | VideoView ref |
videoRef.current.dismissFullscreenPlayer() | videoViewRef.current.exitFullscreen() | VideoView ref |
Event Handling
| v6 Event | v7 Event | Handling |
|---|---|---|
onLoad | onLoad | useEvent hook or direct assignment |
onProgress | onProgress | useEvent hook or direct assignment |
onError | onError | useEvent hook or direct assignment |
| All events as props | All events via hooks | More consistent and cleaner |
Advanced Features
Video Preloading
One of the major benefits of v7 is the ability to preload videos:Multiple Video Players
Managing multiple players is now much cleaner:Troubleshooting
TypeScript Errors
If you encounter TypeScript errors, ensure you have the latest type definitions:Android Error Handling
For React Native < 0.80, apply the nitro modules patch to ensure proper error handling on Android. See the Installation guide.Build Errors on iOS
If you encounter build errors after upgrading:Build Errors on Android
Clean and rebuild:Need Help?
- Check the full documentation
- Join the Discord community
- Review example code
- Contact TWG for professional support
Version Support
| Version | Status | Architecture | Support |
|---|---|---|---|
| v5 and lower | End-of-life | Old Architecture | Commercial only |
| v6 | Maintained | Old + New (Interop) | Community + TWG |
| v7 | Active Development | Old + New (Full) | Active |