Registry / storage / react-native-video-cache-control

react-native-video-cache-control

JSON →
library1.2.4jsnpmunverified

React Native library for caching streaming video to improve playback performance. Version 1.2.4 supports iOS via KTVHTTPCache and Android via AndroidVideoCache, wrapping them in a unified JS API. Provides synchronous and asynchronous proxy URL conversion, optional request headers, cache existence checks, and cache clearing (all or single URL). Ships TypeScript type definitions. Low maintenance cadence; last release 2023.

npm install react-native-video-cache-control
INSTALL
IMPORT
SIG · REACT-NATIVE-VIDEO
R
react-native-video-cache-control
storagejavascriptv1.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convertToProxyURL
import convertToProxyURL from 'react-native-video-cache-control'
import { convertToProxyURL } from 'react-native-video-cache-control'
This is a default export, not named.
convertAsync
import { convertAsync } from 'react-native-video-cache-control'
import convertAsync from 'react-native-video-cache-control'
Named export, do not use default import.
isCached
import { isCached } from 'react-native-video-cache-control'
import isCached from 'react-native-video-cache-control'
Named export, synchronous function.
clearCache
import { clearCache } from 'react-native-video-cache-control'
import clearCache from 'react-native-video-cache-control'
Named export, async function. Optionally pass a URL string to clear single cache.

Synchronous video caching: convert URL to proxy URL and render with react-native-video.

import React from 'react'; import { View } from 'react-native'; import Video from 'react-native-video'; import convertToProxyURL from 'react-native-video-cache-control'; export default function App() { const originalURL = 'https://example.com/video.mp4'; const proxyURL = convertToProxyURL({ url: originalURL }); return ( <View style={{ flex: 1 }}> <Video source={{ uri: proxyURL }} style={{ width: '100%', height: 300 }} /> </View> ); }
Debug
Known issues
breakingOn Android, you must add a Maven repository in android/build.gradle or the build will fail with missing native library.
fix
Add maven { url "$rootDir/../node_modules/react-native-video-cache-control/android/libs" } to allprojects/repositories in android/build.gradle.
affects: >=1.0.0
gotchaThe synchronous convertToProxyURL may block the UI thread if called repeatedly; use convertAsync for heavy usage.
fix
Use the async convertAsync function in performance-critical paths.
affects: >=1.0.0
gotchaclearCache without arguments clears all cache. To delete a single cache, you must pass the exact original URL (including headers if used during caching).
fix
Pass the full URL object (with headers if originally used) to clearCache to delete a single cache entry.
affects: >=1.0.0
deprecatedconvertAsync returns a Promise; make sure to handle errors or use try/catch.
fix
Always wrap convertAsync in try/catch or use .catch() to handle potential caching failures.
affects: >=1.0.0
gotchaisCached is synchronous and may return false for partially cached videos; it only indicates if the full file is cached.
fix
Use isCached only for full cached files; partial caching is not exposed by this library.
affects: >=1.0.0
Errors
Common errors & fixes
Invariant Violation: Native module cannot be null
Missing native module linking or pod install failure on iOS.
fix
Run 'cd ios && pod install' and rebuild the app. Ensure react-native link is done for autolinking.
Could not resolve 'react-native-video-cache-control'
Package not installed or mismatched version.
fix
Run 'yarn add react-native-video-cache-control' or 'npm install react-native-video-cache-control'.
TypeError: convertToProxyURL is not a function
Incorrect import; trying to use as a named export instead of default.
fix
Use 'import convertToProxyURL from 'react-native-video-cache-control'' (default import).
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
reactrequiredPeer dependency required by React Native
react-nativerequiredPeer dependency for native modules
Agent activity
29 hits · last 30 days
node
24
OpenAI (training)
1
Resources
react-native-video-cache-control — npm install react-native-video-cache-control · libregistry