screencapture
Prompt the user to share a screen, window, or tab via the Screen Capture API.
Import: @rtorcato/browser-common/screencapture
getDisplayMedia needs a secure context and throws where unsupported โ guard with isScreenCaptureAvailable() first.
Browser supportโ
| API | Chrome | Edge | Firefox | Safari | iOS Safari | Baseline |
|---|---|---|---|---|---|---|
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 checkgetDisplayMedia(options?)โ prompts the user and resolves to aMediaStream
See the API reference for full signatures.