@capgo/capacitor-downloader

中文文档
8.3.19发布于 2026/11/09MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 7.8万

Download file in background or foreground

原始使用文档
文档目录20 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor Downloader?
  4. Documentation
  5. Compatibility
  6. Install
  7. API
  8. download(...)
  9. pause(...)
  10. resume(...)
  11. stop(...)
  12. checkStatus(...)
  13. getFileInfo(...)
  14. addListener('downloadProgress', ...)
  15. addListener('downloadCompleted', ...)
  16. addListener('downloadFailed', ...)
  17. removeAllListeners()
  18. getPluginVersion()
  19. Interfaces
  20. Credit

@capgo/capacitor-downloader

Download large files in the background or foreground from your Capacitor app, with pause, resume and progress events. Downloads keep going when users leave the screen.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-downloader in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-downloader to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-downloader for Capacitor apps

Key features

  • Downloads: download() starts a task with optional HTTP headers and a wifi-only or cellular network rule.
  • Control: pause(), resume() and stop() for each download ID.
  • Progress events: downloadProgress, downloadCompleted and downloadFailed listeners.
  • Status and files: checkStatus() for a task and getFileInfo() for a downloaded file.
  • Platforms: iOS and Android. iOS uses a background URLSession, Android uses DownloadManager. Not available on web.

Why Capacitor Downloader?

A reliable native file downloader built for Capacitor apps that continues downloads even when your app is backgrounded or closed:

  • Background downloads - Downloads continue even when app is minimized, backgrounded, or closed (main advantage)
  • Progress tracking - Real-time progress updates during downloads
  • Network control - Choose between WiFi-only or cellular network downloads
  • Custom headers - Add authentication tokens and custom HTTP headers
  • Resumable downloads - Pause and resume downloads (platform dependent)
  • Event listeners - Monitor download progress, completion, and failures
  • Large file support - Handle multi-gigabyte files without memory issues
  • Free and open source - No paid services required

Perfect for downloading large media files, offline content, app updates, and any scenario where downloads need to survive app lifecycle events.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/downloader/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-downloader` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-downloader
npx cap sync

API

Capacitor plugin for downloading files with background support. Provides resumable downloads with progress tracking.

download(...)

download(options: DownloadOptions) => Promise<DownloadTask>

Start a new download task.

ParamTypeDescription
optionsDownloadOptions- Download configuration

Returns: Promise<DownloadTask>


pause(...)

pause(options: { id: string; }) => Promise<void>

Pause an active download. Download can be resumed later from the same position.

ParamTypeDescription
options{ id: string; }- Options containing the download task ID

resume(...)

resume(options: { id: string; }) => Promise<void>

Resume a paused download. Continues from where it was paused.

ParamTypeDescription
options{ id: string; }- Options containing the download task ID

stop(...)

stop(options: { id: string; }) => Promise<void>

Stop and cancel a download permanently. Downloaded data will be deleted.

ParamTypeDescription
options{ id: string; }- Options containing the download task ID

checkStatus(...)

checkStatus(options: { id: string; }) => Promise<DownloadTask>

Check the current status of a download.

ParamTypeDescription
options{ id: string; }- Options containing the download task ID

Returns: Promise<DownloadTask>


getFileInfo(...)

getFileInfo(options: { path: string; }) => Promise<{ size: number; type: string; }>

Get information about a downloaded file.

ParamTypeDescription
options{ path: string; }- Options containing the file path

Returns: Promise<{ size: number; type: string; }>


addListener('downloadProgress', ...)

addListener(eventName: 'downloadProgress', listenerFunc: (progress: { id: string; progress: number; bytesWritten?: number | undefined; bytesTotal?: number | undefined; }) => void) => Promise<PluginListenerHandle>

Listen for download progress updates. Fired periodically as download progresses.

ParamTypeDescription
eventName'downloadProgress'- Must be 'downloadProgress'
listenerFunc(progress: { id: string; progress: number; bytesWritten?: number; bytesTotal?: number; }) => void- Callback receiving progress updates

Returns: Promise<PluginListenerHandle>


addListener('downloadCompleted', ...)

addListener(eventName: 'downloadCompleted', listenerFunc: (result: { id: string; }) => void) => Promise<PluginListenerHandle>

Listen for download completion. Fired when a download finishes successfully.

ParamTypeDescription
eventName'downloadCompleted'- Must be 'downloadCompleted'
listenerFunc(result: { id: string; }) => void- Callback receiving completion notification

Returns: Promise<PluginListenerHandle>


addListener('downloadFailed', ...)

addListener(eventName: 'downloadFailed', listenerFunc: (error: { id: string; error: string; }) => void) => Promise<PluginListenerHandle>

Listen for download failures. Fired when a download encounters an error.

ParamTypeDescription
eventName'downloadFailed'- Must be 'downloadFailed'
listenerFunc(error: { id: string; error: string; }) => void- Callback receiving error information

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all event listeners. Cleanup method to prevent memory leaks.


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the plugin version number.

Returns: Promise<{ version: string; }>


Interfaces

DownloadTask

Represents the current state and progress of a download task.

PropTypeDescription
idstringUnique identifier for the download task
progressnumberDownload progress from 0 to 100
state'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR'Current state of the download

DownloadOptions

Configuration options for starting a download.

PropTypeDescriptionSince
idstringUnique identifier for this download task
urlstringURL of the file to download
destinationstringLocal file path where the download will be saved
headers{ [key: string]: string; }Optional HTTP headers to include in the request
network'cellular' | 'wifi-only'Network type requirement for download
priority'high' | 'normal' | 'low'Download priority level
notification'completed' | 'progress' | 'hidden'Android DownloadManager notification visibility. - 'completed' (default): show while downloading and keep the notification after completion. - 'progress': show while downloading, remove the notification when finished. - 'hidden': no system notification; use plugin progress events instead. Ignored on iOS and Web.8.2.0

PluginListenerHandle

PropType
remove() => Promise<void>

Credit

This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader

版本与发布记录

@capgo/capacitor-downloader 共发布 101 个版本,首次发布于 2024/10/25;过去 12 个月发布了 67 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.3.19latest2026/11/09今天
8.3.182026/11/026 天前
8.3.172026/10/2614 天前
8.3.162026/10/1921 天前
8.3.152026/10/1525 天前
8.3.142026/10/1327 天前

其他发布通道:lts-v7 → 7.2.14。

关于 @capgo/capacitor-downloader 的常见问题

@capgo/capacitor-downloader 是什么?

Download file in background or foreground

如何安装 @capgo/capacitor-downloader?

在项目目录运行 npm install @capgo/capacitor-downloader,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-downloader 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-downloader 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-downloader 可以商用吗?

@capgo/capacitor-downloader 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-downloader 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-downloader 在 2026/10/09 – 2026/11/07 这 30 天内被下载 78,475 次,日均约 2,616 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-downloader 还在维护吗?

最新版本 8.3.19 发布于 2026/11/09(今天);至今共发布 101 个版本,其中过去 12 个月发布了 67 个;首次发布于 2024/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。