{"id":43049452,"url":"https://github.com/athexweb3/react-native-bg-upload","last_synced_at":"2026-01-31T10:13:59.644Z","repository":{"id":326321503,"uuid":"1105058515","full_name":"athexweb3/react-native-bg-upload","owner":"athexweb3","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-28T18:26:51.000Z","size":2846,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-11-29T21:58:39.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/athexweb3.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-27T04:38:00.000Z","updated_at":"2025-11-28T18:26:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/athexweb3/react-native-bg-upload","commit_stats":null,"previous_names":["athexweb3/react-native-bg-upload"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/athexweb3/react-native-bg-upload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athexweb3%2Freact-native-bg-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athexweb3%2Freact-native-bg-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athexweb3%2Freact-native-bg-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athexweb3%2Freact-native-bg-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athexweb3","download_url":"https://codeload.github.com/athexweb3/react-native-bg-upload/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athexweb3%2Freact-native-bg-upload/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28937953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T08:53:31.997Z","status":"ssl_error","status_checked_at":"2026-01-31T08:51:38.521Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-31T10:13:59.037Z","updated_at":"2026-01-31T10:13:59.638Z","avatar_url":"https://github.com/athexweb3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003eReact Native Background Upload SDK\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@athex/react-native-bg-upload\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/@athex/react-native-bg-upload?style=flat-square\u0026color=4630EB\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/athexweb3/react-native-bg-upload?style=flat-square\u0026color=4630EB\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eProduction-grade SDK for reliable background file uploads on React Native. Survives app kills, network drops, and device reboots.\u003c/b\u003e\n\u003c/p\u003e\n\n## Features\n\n- **Resumable**: Survives app kills, low memory, and device reboots\n- **Chunking**: Automatic chunking for large files with resume capability\n- **Retry Logic**: Exponential backoff with jitter for transient failures\n- **Network Aware**: Auto pause/resume on connectivity changes\n- **Secure**: Credential refresh hooks, no long-term token storage\n- **Native Notifications**: Foreground service with progress (Android)\n- **Persistent Queue**: MMKV-based storage for instant recovery\n- **React Hooks**: `useUpload()` for seamless integration\n- **Observable**: Progress, completion, error events\n- **Battle Tested**: Comprehensive test suite included\n\n## Platform Support\n\n| Feature               | Android (API 21+) |   iOS (11+)   |\n| :-------------------- | :---------------: | :-----------: |\n| Background Uploads    |  WorkManager      | URLSession    |\n| App Kill Survival     |        Yes        |      Yes      |\n| Device Reboot         |        Yes        |      Yes      |\n| Chunking \u0026 Resume     |        Yes        |      Yes      |\n| Retry \u0026 Backoff       |        Yes        |      Yes      |\n| Progress Notification |        Yes        |      N/A      |\n| Network Monitoring    |        Yes        |      Yes      |\n\n## Installation\n\n```bash\nnpm install react-native-bg-upload react-native-mmkv @react-native-community/netinfo\n# or\nyarn add react-native-bg-upload react-native-mmkv @react-native-community/netinfo\n```\n\n**iOS**: `cd ios \u0026\u0026 pod install`\n\n## Quick Start\n\n```typescript\nimport { BgUpload } from 'react-native-bg-upload';\n\n// Start an upload\nconst taskId = await BgUpload.start({\n  id: 'video-upload-1',\n  url: 'https://api.example.com/upload',\n  path: 'file:///path/to/large-video.mp4',\n  headers: {\n    Authorization: 'Bearer YOUR_TOKEN',\n  },\n  chunking: {\n    enabled: true, // Auto-enabled for files \u003e 5MB\n    chunkSize: 5 * 1024 * 1024, // 5MB chunks\n  },\n  retryPolicy: {\n    maxAttempts: 5,\n    baseDelay: 1000,\n    maxDelay: 30000,\n  },\n  // Android only\n  notification: {\n    enabled: true,\n    title: 'Uploading Video',\n  },\n});\n```\n\n## Using Hooks\n\n```typescript\nimport { useUpload } from 'react-native-bg-upload';\n\nfunction UploadScreen({ taskId }) {\n  const task = useUpload(taskId);\n\n  if (!task) return null;\n\n  return (\n    \u003cView\u003e\n      \u003cText\u003eState: {task.state}\u003c/Text\u003e\n      \u003cText\u003eProgress: {task.progress}%\u003c/Text\u003e\n      \u003cProgressBar progress={task.progress / 100} /\u003e\n\n      {task.state === 'UPLOADING' \u0026\u0026 (\n        \u003cButton title=\"Pause\" onPress={() =\u003e BgUpload.pause(taskId)} /\u003e\n      )}\n\n      {task.error \u0026\u0026 \u003cText style={{color: 'red'}}\u003e{task.error}\u003c/Text\u003e}\n    \u003c/View\u003e\n  );\n}\n```\n\n## API Reference\n\n### `BgUpload.start(options): Promise\u003cstring\u003e`\n\nStart a background upload. Returns the task ID.\n\n#### Options\n\n| Option                | Type       | Required | Description                     |\n| :-------------------- | :--------- | :------: | :------------------------------ |\n| `id`                  | `string`   |    Yes   | Unique task identifier          |\n| `url`                 | `string`   |    Yes   | Upload destination URL          |\n| `path`                | `string`   |    Yes   | Absolute file path (file://)    |\n| `method`              | `string`   |          | HTTP method (default: POST)     |\n| `headers`             | `object`   |          | HTTP headers                    |\n| `networkType`         | `string`   |          | 'ANY', 'WIFI_ONLY', 'UNMETERED' |\n| `chunking`            | `object`   |          | Chunking configuration          |\n| `retryPolicy`         | `object`   |          | Retry configuration             |\n| `onCredentialRefresh` | `function` |          | Token refresh callback          |\n| `notification`        | `object`   |          | Android notification config     |\n\n#### Chunking Options\n\n```typescript\n{\n  enabled?: boolean;       // Enable chunking (default: true for \u003e 5MB)\n  chunkSize?: number;      // Chunk size in bytes (default: 5MB)\n  maxConcurrent?: number;  // Max concurrent chunks (default: 3)\n}\n```\n\n#### Retry Policy\n\n```typescript\n{\n  maxAttempts?: number;   // Max retry attempts (default: 5)\n  baseDelay?: number;     // Base delay in ms (default: 1000)\n  maxDelay?: number;      // Max delay in ms (default: 30000)\n  jitter?: number;        // Random jitter in ms (default: 500)\n}\n```\n\n### Other Methods\n\n- `BgUpload.cancel(taskId)`: Cancel upload\n- `BgUpload.pause(taskId)`: Pause upload\n- `BgUpload.resume(taskId)`: Resume upload\n- `BgUpload.getPending()`: Get all pending uploads\n- `BgUpload.addListener(event, callback)`: Add event listener\n\n## Security\n\n### Credential Refresh\n\n```typescript\nBgUpload.start({\n  id: 'secure-upload',\n  url: 'https://api.example.com/upload',\n  path: filePath,\n  onCredentialRefresh: async () =\u003e {\n    // Refresh your auth token\n    const newToken = await refreshAuthToken();\n    return {\n      Authorization: `Bearer ${newToken}`,\n    };\n  },\n});\n```\n\n### Best Practices\n\n- Use short-lived signed URLs (S3, Azure)\n- Implement `onCredentialRefresh` for token rotation\n- Don't store tokens in upload options (use refresh hook)\n- Use HTTPS only\n- Don't hardcode credentials\n\n## Testing\n\n### Running Tests\n\n```bash\nyarn test                    # Unit tests\nyarn test:integration       # Integration tests (requires mock server)\n```\n\n### Example Test Scenarios\n\n- Large file (1GB+) with chunking\n- App kill during upload → resume\n- Network offline/online toggle\n- Retry on server 500 errors\n- Notification cancel action (Android)\n\nSee [IMPLEMENTATION_NOTES.md](./IMPLEMENTATION_NOTES.md) for server-side contract.\n\n## Implementation Notes\n\n### Android\n\n- Uses `WorkManager` for reliable background execution\n- Foreground Service with notification during active uploads\n- Persists task state to survive process death\n- Chunks stored with offset tracking for resume\n\n### iOS\n\n- Uses `URL Session` background configuration\n- OS handles upload continuation when app is killed\n- Delegate callbacks for progress/completion\n- Task state synced via `UserDefaults`\n\n### Storage\n\n- **Queue**: MMKV for instant read/write\n- **Tasks**: Serialized JSON with chunk metadata\n- **Credentials**: Never persisted (use refresh hook)\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md)\n\n## License\n\nMIT © 2025\n\n## Links\n\n- [API Documentation](./docs)\n- [Security Guide](./SECURITY.md)\n- [Changelog](./CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathexweb3%2Freact-native-bg-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathexweb3%2Freact-native-bg-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathexweb3%2Freact-native-bg-upload/lists"}