The Screen Capture API introduces additions to the existing Media Capture and Streams API to let the user select a screen or portion of a screen (such as a window) to capture as a media stream. This stream can then be recorded or shared with others over the network.
The Screen Capture API is relatively simple to use. Its main method is MediaDevices.getDisplayMedia(), whose job is to ask the user to select a screen or portion of a screen to capture in the form of a MediaStream.
To start capturing video from the screen, you call getDisplayMedia() on navigator.mediaDevices:
captureStream = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
The Promise returned by getDisplayMedia() resolves to a MediaStream which streams the captured display surface.
See the article Using the Screen Capture API for a more in-depth look at how to use the API to capture screen contents as a stream.
The Screen Capture API has additional features that extend its capabilities:
See Using the Element Capture and Region Capture APIs to learn more.
The Captured Surface Control API allows the capturing application to provide limited control over the captured display surface, for example zooming and scrolling its contents.
See Using the Captured Surface Control API to learn more.
BrowserCaptureMediaStreamTrackRepresents a single video track; extends the MediaStreamTrack class with methods to limit the part of a self-capture stream (for example, a user's screen or window) that is captured.
CaptureControllerProvides methods that can be used to further manipulate a captured display surface (captured via MediaDevices.getDisplayMedia()). A CaptureController object is associated with a captured display surface by passing it into a getDisplayMedia() call as the value of the options object's controller property.
CropTargetProvides a static method, fromElement(), which returns a CropTarget instance that can be used to crop a captured video track to the area in which a specified element is rendered.
RestrictionTargetProvides a static method, fromElement(), which returns a RestrictionTarget instance that can be used to restrict a captured video track to a specified DOM element.
MediaDevices.getDisplayMedia()The getDisplayMedia() method is added to the MediaDevices interface. Similar to getUserMedia(), this method creates a promise that resolves with a MediaStream containing the display area selected by the user, in a format that matches the specified options.
The Screen Capture API adds properties to the following dictionaries defined by other specifications.
MediaTrackConstraints.displaySurfaceA ConstrainDOMString indicating what type of display surface is to be captured. The value is one of browser, monitor, or window.
MediaTrackConstraints.logicalSurfaceIndicates whether or not the video in the stream represents a logical display surface (that is, one which may not be entirely visible onscreen, or may be completely offscreen). A value of true indicates a logical display surface is to be captured.
MediaTrackConstraints.suppressLocalAudioPlaybackControls whether the audio playing in a tab will continue to be played out of a user's local speakers when the tab is captured, or whether it will be suppressed. A value of true indicates that it will be suppressed.
MediaTrackSettings.cursorA string which indicates whether or not the display surface currently being captured includes the mouse cursor, and if so, whether it's only visible while the mouse is in motion or if it's always visible. The value is one of always, motion, or never.
MediaTrackSettings.displaySurfaceA string indicating what type of display surface is currently being captured. The value is one of browser, monitor, or window.
MediaTrackSettings.logicalSurfaceA boolean value, which is true if the video being captured doesn't directly correspond to a single onscreen display area.
MediaTrackSettings.suppressLocalAudioPlaybackA boolean value, which is true if the audio being captured is not played out of the user's local speakers.
MediaTrackSettings.screenPixelRatioA number representing the ratio of the physical size of a pixel on the captured display surface (displayed at its physical resolution) to the logical size of a CSS pixel on the capturing screen (displayed at its logical resolution). It cannot be used as a constraint or capability.
MediaTrackSupportedConstraints.displaySurfaceA boolean, which is true if the current environment supports the MediaTrackConstraints.displaySurface constraint.
MediaTrackSupportedConstraints.logicalSurfaceA boolean, which is true if the current environment supports the constraint MediaTrackConstraints.logicalSurface.
MediaTrackSupportedConstraints.suppressLocalAudioPlaybackA boolean, which is true if the current environment supports the constraint MediaTrackConstraints.suppressLocalAudioPlayback.
Websites that support Permissions Policy (either using the HTTP Permissions-Policy header or the <iframe> attribute allow) can specify a desire to use the Screen Capture API using the directive display-capture:
<iframe allow="display-capture" src="/some-other-document.html">…</iframe>
A site can also specify a desire to use the Captured Surface Control API via the captured-surface-control directive. Specifically, the forwardWheel(), increaseZoomLevel(), decreaseZoomLevel(), and resetZoomLevel() methods are controlled by this directive.
The default allowlist for both directives is self, which permits any content within the same origin use Screen Capture.
These methods are considered powerful features, which means that even if permission is allowed via a Permissions-Policy, the user will still be prompted for permission to use them. The Permissions API can be used to query the aggregate permission (from both the website and the user) for using the listed features.
In addition, the specification requires that a user has recently interacted with the page to use these features — this means that transient activation is required. See the individual method pages for more details.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Screen_Capture_API |
72 | 7917–79Available as a member ofNavigator instead of MediaDevices. |
6633–66Since Firefox 33 you can capture screen data usinggetUserMedia(), with a video constraint called mediaSource. Before 52 it relied on a client-configurable list of allowed sites. |
60 | 13 | NoFrom Chrome Android 72 to 88, this method was exposed, but always failed withNotAllowedError. See bug 40418135. |
NoFrom Firefox Android 66 to 79, this method was exposed, but always failed withNotAllowedError. |
NoFrom Opera Android 51 to 88, this method was exposed, but always failed withNotAllowedError. See bug 40418135. |
No | NoFrom Samsung Internet 11.0 to 88, this method was exposed, but always failed withNotAllowedError. See bug 40418135. |
NoFrom WebView Android 72 to 88, this method was exposed, but always failed withNotAllowedError. See bug 40418135. |
No |
audio_capture_support |
74On Windows and ChromeOS, the entire system audio can be captured when sharing an entire screen. On Linux and macOS, only the audio of a tab can be captured. |
79On Windows and ChromeOS, the entire system audio can be captured when sharing an entire screen. On Linux and macOS, only the audio of a tab can be captured. |
No | 62On Windows and ChromeOS, the entire system audio can be captured when sharing an entire screen. On Linux and macOS, only the audio of a tab can be captured. |
No | No | No | No | No | No | No | No |
controller_option |
109 | 109 | No | 95 | No | No | No | No | No | No | No | No |
monitorTypeSurfaces_option |
119Default value =include |
119Default value =include |
No | 105Default value =include |
No | No | No | No | No | No | No | No |
preferCurrentTab_option |
94Default value =false |
94Default value =false |
No | 80Default value =false |
No | No | No | No | No | No | No | No |
selfBrowserSurface_option |
112Default value =exclude107–111Default value =include |
112Default value =exclude107–111Default value =include |
No |
98Default value =exclude93–97Default value =include |
No | No | No | No | No | No | No | No |
surfaceSwitching_option |
107Default value =exclude |
107Default value =exclude |
No | 93Default value =exclude |
No | No | No | No | No | No | No | No |
systemAudio_option |
105Default value =include |
105Default value =include |
No | 91Default value =include |
No | No | No | No | No | No | No | No |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Screen_Capture_API |
104 | 104 | No | 90 | No | No | No | No | No | No | No | No |
fromElement_static |
104 | 104 | No | 90 | No | No | No | No | No | No | No | No |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Screen_Capture_API |
132 | 132 | No | 117 | No | No | No | No | No | No | No | No |
fromElement_static |
132 | 132 | No | 117 | No | No | No | No | No | No | No | No |
MediaDevices.getDisplayMedia()
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API