Skip to main content
This feature is still in the final beta round. To request access as a beta tester, send an email to offlinemode@despia.com
Cache remote files locally for offline access. Background downloads continue when users close the app, using native OS transfer APIs (NSURLSession on iOS, WorkManager on Android) with built-in retry.

Installation


API Reference

Write

Download and cache a remote file. Fire-and-forget - do not await.
Do not await the write call with a key. The JS bridge has a ~30s timeout. Large files will cause it to resolve with null even though the download continues. Use the contentServerChange callback instead.
string
required
Remote file URL to download
string
required
Local path: folder/subfolder/filename
string
required
Unique ID for this file
boolean
Set to true to show push notification on completion
string
Notification message (wrap in quotes)
If you need more control, poll via localcdn://read to check download status instead of relying solely on the callback.

Read

Get metadata for specific cached files by ID.
array
Array of cached file objects

Query

Return all cached files. Use this to get a full inventory without specifying individual IDs.
array
Array of all cached file objects across all folders
localcdn://query returns every item in the cache. To fetch specific files by ID, use localcdn://read instead.

Delete

Remove cached files.

contentServerChange callback

Called by the native runtime when a download completes. This is where you get the file data.
The callback fires when a download completes in the foreground, and when the app reopens after background downloads completed.

Response schema

string
Full file path (e.g., videos/samples/bigbunny.mp4)
string
Your unique identifier
string
File extension (mp4, mp3, json)
string
Absolute device path
string
Use this for playback - localhost URL
string
Original remote URL
string
File size in bytes
string
Cache status ("cached")
string
Unix timestamp

Background downloads

Downloads continue when users close the app. The native OS handles retry on network failure. On iOS, a Live Activity is shown automatically with real-time download progress. On Android, a native download progress notification appears in the system tray. Both require no setup. When the app reopens, the native layer finds any pending items and calls contentServerChange(item) for each completed download automatically.

Playback

Use the local_cdn URL for offline playback:

HTTP upload API

Only available when your app is served via Despia Local Server (not from origin/remote server).
Upload user files via HTTP POST:

React hook


Environment check


Test videos

Free sample videos for testing Local CDN (CC licensed):

Resources

NPM Package

despia-native