Set up resumable uploads for React Native
The FastPix React Native Uploads SDK adds resumable, chunked uploads to your React Native app. It uploads large videos in chunks, retries failed chunks on its own, and resumes from the last confirmed byte after a pause or a dropped connection, so an interrupted upload continues instead of starting over. It works on both Android and iOS.
Uploads go straight from the device to FastPix, so the video bytes never pass through your own server.
How resumable uploads work through chunking
A resumable upload splits a large file into smaller pieces, called chunks, and uploads them one at a time:
- Split the file. The file is divided into smaller chunks (5 MB by default).
- Upload each chunk. Each chunk is sent separately. The server confirms each one.
- Resume from the last chunk. If the upload is interrupted, it continues from the last confirmed chunk instead of starting over.
This matters because:
- It lowers the risk. If a chunk fails on a flaky network, only that chunk is retried, not the whole file.
- It performs better. Smaller chunks transfer more reliably on slow or mobile connections.
- It is easier to manage. Chunk-by-chunk progress makes features like pause, resume, and progress bars straightforward.
Platform support
Install the SDK
Install the package with npm or your preferred package manager:
The SDK bundles its runtime dependencies (@react-native-community/netinfo, react-native-blob-util, and axios), so there are no peer dependencies to install manually.
iOS: the native modules auto-link on React Native 0.70+. After installing the package, install the pods:
Android: no manual linking or extra setup is required. The native modules auto-link.
Note: The SDK depends on native modules, so it does not run in Expo Go. In an Expo project, use a development build (
npx expo run:iosornpx expo run:android). For a full Expo walkthrough, see Upload videos from a React Native app.
Generate a signed upload URL
The SDK uploads to a signed URL: a pre-authorized, short-lived URL that lets the device upload directly to FastPix without exposing your API credentials in the app.
To create one, you need a valid Access Token and Secret Key. See the Basic Authentication guide for how to retrieve them. Then call the Upload media from device API to get the signed URL.
Never ship your Access Token or Secret Key in the app bundle. Create signed URLs on your backend and return only the signed URL to the device.
The service below calls the Direct Upload API and returns a signed URL. This is your backend code, not part of the SDK. It uses axios and base-64 for the Basic Auth header (npm install axios base-64); on a Node backend you can drop base-64 and use Buffer.from(...).toString("base64") instead.
Upload a file
Create a FastPixUpload with the signed URL and the local file URI, then call start():
Because endpoint also accepts an async factory (() => Promise<string>), you can plug the signed-URL generator in directly. The factory runs once when start() is called, so the URL is created fresh and your token stays on your backend:
Configuration parameters
The FastPixUpload constructor accepts these options:
Pause, resume, and network recovery
Every chunk that finishes is confirmed by the server, so a paused or interrupted upload always continues from the last confirmed byte. Completed chunks are never re-sent.
An upload can pause in two ways:
Both cases emit a pause event with a reason ('user' or 'network'), so your UI can respond:
An upload you paused (reason: 'user') is not auto-resumed on reconnect. That stays under your control, so a user-paused upload never restarts on its own.
Chunk-level retry tracking
Retries are tracked per chunk, not with one global counter. Each chunk gets its own budget of maxRetries attempts with exponential back-off, so one flaky chunk cannot use up the retry allowance of the others. On a network blip, only the in-flight chunk retries, and completed chunks are never re-uploaded.
Watch it live through the chunk events:
Lifecycle events
Subscribe with upload.on(event, handler). Each subscription returns an unsubscribe function, which makes cleanup in React’s useEffect straightforward.
Control methods
The SDK also exposes state, progress, and stateHistory getters. The upload moves through these states:
Full example: progress bar with pause, resume, and abort
A complete component wiring the lifecycle to UI controls:
Troubleshooting
Set enableLogs: true in the constructor to see detailed SDK logs while diagnosing issues, and disable it in production.
Frequently asked questions
What is a resumable upload?
A resumable upload is a way to transfer a file that lets you pause, or recover from a network drop or interruption, without starting over from the beginning. The file is sent in sequential chunks, the server tracks how many bytes it has confirmed, and the upload continues from that last confirmed offset. It is the same pattern used by standards like the open-source tus protocol, and it is what makes large uploads reliable on mobile networks.
Does the upload keep going if the app is backgrounded or closed?
While the app is running, the SDK recovers on its own: it pauses when connectivity drops or the connection switches between Wi-Fi and cellular, then resumes from the last confirmed byte when the network returns. It does not perform OS-level background uploading after the app is suspended or terminated, so keep the upload screen in the foreground until it finishes.
What is a signed upload URL?
A signed upload URL is a short-lived, pre-authorized URL that lets a device upload directly to FastPix without carrying your Access Token or Secret Key. You create it on your backend with the Direct Upload API and return only the URL to the app, so your credentials never ship in the app bundle.
Does the SDK work in Expo Go?
No. The SDK depends on native modules, which Expo Go does not include, so you get a “native module that doesn’t exist” error. Use an Expo development build (npx expo run:ios or npx expo run:android) to run uploads on a device.
What chunk size and file size can I use?
Chunk size must be between 5 MB and 500 MB and a multiple of 256 KB, so any N * 1024 value works. The default is 5 MB. maxFileSize is optional and in KB; set it to 0 for no limit.
What’s next
- Upload videos from a React Native app for a full Expo walkthrough with a video picker and playback.
- Set up resumable uploads for Web for the browser SDK.
- Play your videos once FastPix has processed the upload.