npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lachuuuk/react-native-file-downloader

v1.0.0

Published

Zero-dependency file downloader for React Native with custom headers, progress tracking, retry, resume, app-folder/subfolder, a 'save to…' picker, and multi-platform storage support

Readme

React Native File Downloader

A zero-dependency React Native package for downloading files with advanced features like custom headers, progress tracking, automatic retry, resume capability, and multi-platform storage support.

🎯 Features

  • ✅ Download files from HTTP/HTTPS URLs
  • ✅ Custom HTTP headers (auth tokens, API keys)
  • ✅ Real-time progress tracking (bytes, %, speed, ETA)
  • Status-bar progress notification (Android)
  • Save into an app-named folder or any subfolder
  • Native "Save to…" picker (Android SAF / iOS Files)
  • ✅ Automatic retry with exponential backoff (max 3 retries)
  • ✅ Resume interrupted downloads
  • ✅ Multiple storage locations (Downloads, Documents, Cache, Custom)
  • ✅ Automatic permission handling (Android & iOS)
  • ✅ Smart file naming with timestamps
  • ✅ File-manager visibility (Android MediaStore)
  • ✅ Zero external dependencies

📱 Platform Support

  • Android: 5.0+ (API 21+)
  • iOS: 11.0+
  • Bare React Native or Expo dev build (not Expo Go — it contains native code).

🚀 Quick Start

Installation

npm install @lachuuuk/react-native-file-downloader
# iOS:
cd ios && pod install

Android autolinks automatically. Requires a native rebuild after install (npx react-native run-android / run-ios, or npx expo run:*).

Basic Usage

import { DownloadManager } from '@lachuuuk/react-native-file-downloader';

DownloadManager.download(
  { url: 'https://example.com/file.pdf' },
  {
    onProgress: (p) => console.log(`${p.percentage}%`),
    onSuccess: (r) => console.log(`Downloaded: ${r.filePath}`),
    onError: (e) => console.error(e.message),
  }
);

With Custom Headers

DownloadManager.download(
  {
    url: 'https://api.example.com/secure-file.zip',
    headers: {
      'Authorization': `Bearer ${token}`,
      'X-API-Key': apiKey,
    },
    storageLocation: 'documents'
  },
  {
    onSuccess: (result) => console.log(result.filePath),
    onError: (error) => console.error(error.message),
  }
);

Status-bar progress notification (Android)

import { PermissionsAndroid, Platform } from 'react-native';

// Android 13+ requires the notification permission.
if (Platform.OS === 'android' && Number(Platform.Version) >= 33) {
  await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
}

DownloadManager.download(
  {
    url: 'https://example.com/large.zip',
    showNotification: true,
    notificationTitle: 'Downloading report',
  },
  { onSuccess: (r) => console.log(r.filePath) }
);

Save into an app-named folder (or a custom subfolder)

DownloadManager.download(
  {
    url: 'https://example.com/invoice.pdf',
    storageLocation: 'downloads',
    useAppFolder: true,      // → Download/<YourAppName>/invoice.pdf
    // subfolder: 'Invoices' // → Download/Invoices/invoice.pdf (takes precedence)
  },
  { onSuccess: (r) => console.log(r.filePath) }
);

Let the user choose where to save (native picker)

import { DownloadManager, StorageHandler } from '@lachuuuk/react-native-file-downloader';

DownloadManager.download(
  { url: 'https://example.com/report.pdf', storageLocation: 'cache' },
  {
    onSuccess: async (r) => {
      // Android → "Save to…" (SAF); iOS → "Save to Files".
      const res = await StorageHandler.saveWithPicker(r.filePath, 'report.pdf');
      console.log(res.saved ? `Saved to ${res.uri}` : 'User cancelled');
    },
  }
);

📚 Documentation

📋 Core API

DownloadManager

// Start a download
DownloadManager.download(config: DownloadConfig, callbacks: DownloadCallbacks): string

// Control downloads
DownloadManager.pause(downloadId: string): Promise<void>
DownloadManager.resume(downloadId: string): Promise<void>
DownloadManager.cancel(downloadId: string): Promise<void>
DownloadManager.getStatus(downloadId: string): Promise<DownloadProgress>

StorageHandler

StorageHandler.getStoragePaths(): Promise<StoragePath[]>
StorageHandler.createCustomFolder(name: string): Promise<string>
StorageHandler.deleteFile(path: string): Promise<void>
StorageHandler.fileExists(path: string): Promise<boolean>

PermissionManager

PermissionManager.checkPermissions(): Promise<boolean>
PermissionManager.requestPermissions(): Promise<boolean>

🏗️ Architecture

TypeScript Layer (DownloadManager, StorageHandler, PermissionManager)
         ↓
Native Module Bridge
         ↓
Platform-Specific (Kotlin + Swift)
         ↓
Native APIs

🔒 Security

  • ✅ HTTPS support and validation
  • ✅ Input validation and sanitization
  • ✅ Path traversal protection
  • ✅ Timeout protection (30s default)
  • ✅ Secure header transmission

📊 Performance

  • Chunk-based streaming (64KB default)
  • Non-blocking progress updates
  • Efficient memory usage for large files
  • Exponential backoff retry strategy

🆘 Error Handling

Retryable Errors (Auto-retry)

  • Network errors
  • Timeouts
  • 5xx server errors

Non-Retryable Errors

  • Invalid URL (4xx)
  • Permission denied
  • Storage full
  • Invalid path

📝 License

MIT

🙏 Contributing

Pull requests welcome! Please read our contributing guidelines.

📮 Support

For issues and questions, please open an issue on GitHub.


Status: ✅ Implemented (TypeScript + Android/Kotlin + iOS/Swift), type-checked, and unit-tested

Version: 1.0.0

Last Updated: 2026-05-25