Docs

Downloads (window.Electron.downloads)

HTTP(S) file downloads through Electron's own download machinery, with progress events streamed back to the renderer. Source: src/main/downloads.ts, channel prefix downloads:*. Always on, no config needed — createElectronBridge() sends a one-time downloads:ensureSession signal per window on startup so the session's download listener is attached even before you call anything.

Methods

Method Returns Notes
start(options: { url: string; savePath?: string }) Promise<DownloadState> Only http:/https: URLs. Throws VALIDATION for a missing/invalid/non-http(s) URL. Resolves immediately with the initial ('requested') state — the actual transfer progress arrives via on().
pause(id: string) Promise<void> No-op if id isn't currently active.
resume(id: string) Promise<void>
cancel(id: string) Promise<void>
getActive() Promise<DownloadState[]> Snapshot of every in-progress download.
on(callback: (event: { type: string; data: DownloadState }) => void) () => void (unsubscribe) See event types below.

DownloadState

{ id, url, filename, savePath?, state: 'requested' | 'progressing' | 'completed' | 'cancelled' | 'interrupted', receivedBytes, totalBytes }

Events

on() delivers { type, data: DownloadState } where type is one of 'started', 'updated', or a terminal type matching data.state ('completed', 'cancelled', 'interrupted').

Example

const unsubscribe = window.Electron.downloads.on(({ type, data }) => {
  console.log(type, data.id, `${data.receivedBytes}/${data.totalBytes}`);
});

const { id } = await window.Electron.downloads.start({ url: 'https://example.com/file.zip' });
// later, if needed:
await window.Electron.downloads.pause(id);
await window.Electron.downloads.resume(id);

.safe

Partial. start, pause, resume, cancel, getActive are wrapped — window.Electron.safe.downloads.* resolves { ok: true, data } / { ok: false, error } instead of throwing. on() is the same function on both surfaces (event subscription, never throws).

Last updated on July 18, 2026