A high-performance native HTTP client for React Native, built with Nitro Modules.
- File download
- Native performance — Uses
URLSessionon iOS andOkHttpon Android - Resumable downloads — Pause and resume downloads with HTTP Range requests
- Background downloads — Continue downloading while the app is in the background
- Progress tracking — Real-time
onProgressandbegincallbacks - Configurable timeouts — Set connection and read timeouts independently
- Native performance — Uses
npm install react-native-client react-native-nitro-modules
# or
yarn add react-native-client react-native-nitro-modules
# or
bun add react-native-client react-native-nitro-modulescd ios && pod installNo additional steps required — Gradle handles everything automatically.
import { downloadFile, documentDirectoryPath } from 'react-native-client'
const result = await downloadFile({
fromUrl: 'https://example.com/file.zip',
toFile: `${documentDirectoryPath}/file.zip`,
})
console.log(`Status: ${result.statusCode}, Bytes: ${result.bytesWritten}`)import { downloadFile, documentDirectoryPath } from 'react-native-client'
const result = await downloadFile({
fromUrl: 'https://example.com/large-file.zip',
toFile: `${documentDirectoryPath}/large-file.zip`,
begin: (statusCode, contentLength) => {
console.log(`Download started — ${contentLength} bytes`)
},
onProgress: (bytesWritten, contentLength) => {
const percent = ((bytesWritten / contentLength) * 100).toFixed(1)
console.log(`${percent}%`)
},
})import { downloadFile, documentDirectoryPath } from 'react-native-client'
const result = await downloadFile({
fromUrl: 'https://example.com/large-file.zip',
toFile: `${documentDirectoryPath}/large-file.zip`,
resumable: true,
background: true,
connectionTimeout: 30000,
readTimeout: 30000,
onProgress: (bytesWritten, contentLength) => {
console.log(`${bytesWritten} / ${contentLength}`)
},
})Downloads a file from a remote URL to a local path.
The app's document directory path, useful as a base path for toFile.
| Property | Type | Required | Description |
|---|---|---|---|
fromUrl |
string |
Yes | URL to download from |
toFile |
string |
Yes | Local file path to save to |
resumable |
boolean |
No | Enable resumable downloads via HTTP Range |
background |
boolean |
No | Continue download in the background |
discretionary |
boolean |
No | iOS only — marks the transfer as discretionary |
progressDivider |
number |
No | Controls progress callback frequency |
connectionTimeout |
number |
No | Connection timeout in milliseconds |
readTimeout |
number |
No | Read timeout in milliseconds |
onProgress |
(bytesWritten, contentLength) => void |
No | Called periodically with download progress |
begin |
(statusCode, contentLength) => void |
No | Called when the download begins |
| Property | Type | Description |
|---|---|---|
statusCode |
number |
HTTP status code (200, 206, etc.) |
bytesWritten |
number |
Total bytes written to disk |
Contributions are welcome! This library is actively growing and we appreciate help from the community.
- Fork the repository
- Clone your fork:
git clone https://github.com/<your-username>/react-native-client.git
- Install dependencies:
bun install
- Create a branch for your changes:
git checkout -b feat/my-feature
# Type check
bun run typecheck
# Lint
bun run lint
# Regenerate Nitro specs after changing .nitro.ts files
bun run specs
# Regenerate nitrogen bindings after changing Client.nitro.ts
bunx nitrogenThis project is licensed under the MIT License - see the LICENSE file for details.