Skip to main content

screencapture

Prompt the user to share a screen, window, or tab via the Screen Capture API.

Import: @rtorcato/browser-common/screencapture

๐Ÿ“– MDN: Screen Capture API

getDisplayMedia needs a secure context and throws where unsupported โ€” guard with isScreenCaptureAvailable() first.

Browser supportโ€‹

APIChromeEdgeFirefoxSafariiOS SafariBaseline
MediaDevices.getDisplayMediaโœ… 72+โœ… 79+โœ… 66+โœ… 13+โŒLimited

โœ… supported ยท โ— partial ยท โŒ not supported ยท [n] see note. Generated from MDN browser-compat-data and web-features. caniuse: MediaDevices.getDisplayMedia

Exampleโ€‹

import { isScreenCaptureAvailable, getDisplayMedia } from '@rtorcato/browser-common/screencapture'

if (isScreenCaptureAvailable()) {
const stream = await getDisplayMedia({ video: true })
}

Exportsโ€‹

  • isScreenCaptureAvailable() โ€” feature check
  • getDisplayMedia(options?) โ€” prompts the user and resolves to a MediaStream

See the API reference for full signatures.