expodl
v1.0.3
Published
Lightweight Expo file download utility with caching, cancellation, and headers support.
Maintainers
Readme
expodl
Lightweight Expo file download utility with caching, cancellation, and headers support.
Features
- 🎣 Hook API –
useDownload()with built-in state - ❌ Cancellation – stop downloads mid-flight
- 🔐 Custom Headers – auth tokens, signed URLs
- 💾 Smart Caching – skip re-downloading files
Installation
npm install expodlQuick Start
import { useDownload } from 'expodl';
export default function App() {
const { download, isDownloading, progress, cancel } = useDownload();
return (
<View>
<Button
title={isDownloading ? `${Math.round(progress * 100)}%` : 'Download'}
onPress={() => download('https://example.com/image.jpg')}
disabled={isDownloading}
/>
{isDownloading && <Button title="Cancel" onPress={cancel} />}
</View>
);
}That's it! 🎉
Documentation
- 📖 API Reference - Complete API documentation
- 💡 Examples - Advanced usage examples
Common Use Cases
Download with Authentication
const { download } = useDownload({
headers: { Authorization: 'Bearer your-token' },
});
await download('https://api.example.com/protected/file.pdf');Smart Caching
const { download } = useDownload({
cache: true,
overwrite: false, // Skip if already exists
});
await download('https://example.com/avatar.jpg');Function API (Advanced)
import { downloadFile } from 'expodl';
const result = await downloadFile({
url: 'https://example.com/file.pdf',
fileName: 'my-file.pdf',
onProgress: (progress) => console.log(progress),
});Requirements
- Expo SDK 47+ (tested up to SDK 53)
- React Native 0.70+ (tested up to 0.81)
- React 17+
License
MIT © Pavan Kommi
