State-driven, resumable download API for Tauri 2.x apps.
- 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.
Note: These steps are an interim workaround until the plugin is published.
Add the tauri-plugin-download
crate to your Cargo.toml
:
[dependencies]
tauri-plugin-download = { git = "https://github.com/silvermine/tauri-plugin-download.git" }
Install the TypeScript bindings via npm:
npm install github:@silvermine/tauri-plugin-download
Initialize 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.
We genuinely appreciate external contributions. See our extensive documentation on how to contribute.
This software is released under the MIT license. See the license file for more details.