State-driven, resumable download API for Tauri 2.x apps.
This plugin provides a cross-platform download interface with resumable downloads, progress tracking, and proper resource management.
- Parallel, resumable download support
- Persistable, thread-safe store
- State and progress notifications
- Cross-platform support (Linux, Windows, macOS, Android, iOS)
| Platform | Supported |
|---|---|
| Linux | ✓ |
| Windows | ✓ |
| macOS | ✓ |
| Android | ✓ |
| iOS¹ | ✓ |
¹ Supports fully interruptible and resumable background downloads, even when the app
is suspended or terminated using
URLSession with a
background configuration.
-
Install NPM dependencies:
npm install
-
Build the TypeScript bindings:
npm run build
-
Build the Rust plugin:
cargo build
Run Rust tests:
cargo testThis plugin requires a Rust version of at least 1.77.2
Add the plugin to your Cargo.toml:
src-tauri/Cargo.toml
[dependencies]
tauri-plugin-download = { git = "https://github.com/silvermine/tauri-plugin-download" }Install the JavaScript bindings:
npm install @silvermine/tauri-plugin-downloadInitialize the plugin in your tauri::Builder:
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_download::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}import { create } from 'tauri-plugin-download';
async function createDownload() {
const key = 'file.zip',
url = 'https://example.com/file.zip',
path = await join(await appDataDir(), 'downloads', key);
const download = await create(key, url, path);
console.debug(`Created '${download.key}':${download.url}`);
}import { list } from 'tauri-plugin-download';
async function listDownloads() {
const downloads = await list();
for (let download of downloads) {
console.debug(`Found '${download.key}':${download.url} [${download.state}, ${download.progress}%]`)
}
}import { get } from 'tauri-plugin-download';
async function getDownload() {
const download = await get('file.zip');
console.debug(`Found '${download.key}':${download.url} [${download.state}, ${download.progress}%]`)
}import { get } from 'tauri-plugin-download';
async function getDownloadAndUpdate() {
const download = await get('file.zip');
download.start();
download.pause();
download.resume();
download.cancel();
}import { get } from 'tauri-plugin-download';
async function getDownloadAndListen() {
const download = await get('file.zip');
const unlisten = await download.listen((updatedDownload) => {
console.debug(`'${updatedDownload.key}':${updatedDownload.progress}%`);
});
// To stop listening
unlisten();
}Check out the examples/tauri-app directory for a working example of how to use this plugin.
This project follows the Silvermine standardization guidelines. Key standards include:
- EditorConfig: Consistent editor settings across the team
- Markdownlint: Markdown linting for documentation
- Commitlint: Conventional commit message format
- Code Style: 3-space indentation, LF line endings
npm run standardsMIT
Contributions are welcome! Please follow the established coding standards and commit message conventions.