Seamless file uploads that continue even when your app goes to background. Pausable, resumable, and built for the S3 API. react-native-s3-bg-uploader is a react native package built with Nitro and Rust. It is compiled to native modules on iOS and Android, and to WebAssembly for the web. On iOS it uses a BGContinuedProcessingTask and on Android a foreground service.
- React Native v0.76.0 or higher
- Node 18.0.0 or higher
- background uploading is only supported for iOS 26 or later
- enabled "background fetch" & "background processing" capabilities
- registered BGTaskSchedulerPermittedIdentifiers of value $(PRODUCT_BUNDLE_IDENTIFIER).background inside info.plist
npm install react-native-s3-bg-uploader react-native-nitro-modulesimport { S3BgUploader } from 'react-native-s3-bg-uploader'
// Configure backend endpoints once (e.g. in app startup)
S3BgUploader.setConfig(
'https://api.example.com/upload/startUpload',
'https://api.example.com/upload/getUploadUrls',
'https://api.example.com/upload/completeUpload',
)
// Track progress
S3BgUploader.setProgressCallback((file, session, transfer) => {
console.log(`${transfer.percentage}% — ${file.fileName}`)
})
// Enqueue files and start
const transferId = 'my-transfer'
await S3BgUploader.uploadFile('/path/to/file.mp4', transferId, { userId: '42' })
await S3BgUploader.resume()
// Pause / resume / cancel
S3BgUploader.pause()
await S3BgUploader.resume()
S3BgUploader.cancel()For the full API reference see the documentation.
For native platforms:
npm run build:ios
npm run build:androidFor web:
npm run build:wasm- rustup
- iOS: Xcode with Command Line Tools (
xcode-select --install) - Android: Android SDK with NDK — set
ANDROID_NDK_HOMEorANDROID_NDK_ROOT, install cargo-ndk (cargo install cargo-ndk)
npm install
npm run example:ios
npm run example:android
npm run example:webImportant
Background uploads on iOS only work on a physical device as the simulator does not support the BGContinuedProcessingTask API.
Important
Please do not upload confidential files. The example app is connected to a demo s3 bucket. Files are only deleted irregularly from this bucket.
Follow the instructions here to generate an upload key and to set required gradle variables.
After that:
cd example
npx react-native build-android --mode=release
npm run android -- --mode="release"Change build configuration to production inside XCode: Open S3BackgroundUploaderExample.xcworkspace and edit the scheme.
Run in the root of the repo
npm run build:rust:wasmBootstrapped with create-nitro-module.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
