Docs

Desktop capture (window.Electron.desktopCapture)

Enumerates screen/window sources for screen sharing or recording. Source: src/main/desktop-capture.ts, channel prefix desktopCapture:*. Always on, no config needed.

Methods

getSources(options?: {
  types?: Array<'window' | 'screen'>;      // default: ['window', 'screen']
  thumbnailSize?: { width: number; height: number }; // default: { width: 320, height: 180 }
  fetchWindowIcons?: boolean;              // default: true
}): Promise<DesktopCaptureSource[]>

DesktopCaptureSource

{ id, name, display_id, thumbnail?, appIcon? }thumbnail/appIcon are data: URLs (omitted, not empty strings, when Electron returns an empty image).

Example

const sources = await window.Electron.desktopCapture.getSources({ types: ['screen'] });
const stream = await navigator.mediaDevices.getUserMedia({
  audio: false,
  video: { mandatory: { chromeMediaSource: 'desktop', chromeMediaSourceId: sources[0].id } },
});

getSources() only enumerates sources — actually capturing the stream still goes through the renderer's own navigator.mediaDevices.getUserMedia() with chromeMediaSourceId set to the chosen source's id, same as any Electron app.

.safe

Fully mirrored — window.Electron.safe.desktopCapture.getSources() resolves { ok: true, data } / { ok: false, error } instead of throwing.

Last updated on July 18, 2026