--- url: "https://web.dev/articles/media/screen-record" titulek: "How to record the user's screen | Media patterns | web.dev" h1: "How to record the user's screen Stay organized with collections Save and categorize content based on your preferences." popis: "" jazyk: "en" kanonicka: "https://web.dev/articles/media/screen-record" drobecky: ["Media patterns", "How to record the user's screen"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 23:12:08" znaku: 3580 slov: 394 kodovani: "iso-8859-2" sha256: "e748146e94d5d4bdfc92d95948c54894ddfc84470b570e9b8b351eee4c4ad4e1" --- How to record the user's screen Stay organized with collections Save and categorize content based on your preferences. François Beaufort Sharing tabs, windows, and screens is possible on the web platform with the [Screen Capture API](https://w3c.github.io/mediacapture-screen-share/). The [`getDisplayMedia()`](https://developer.mozilla.org/docs/Web/API/MediaDevices/getDisplayMedia) method allows the user to select a screen to capture as a media stream. This stream can then be recorded with the [MediaRecorder API](https://developer.chrome.com/blog/mediarecorder) or shared with others over the network. The recording can be saved to a local file via the [`showOpenFilePicker()`](https://developer.mozilla.org/docs/Web/API/Window/showOpenFilePicker) method. The example below shows how you can record the user's screen in the WebM format, locally preview on the same page, and save the recording to the user's file system. `let stream; let recorder; shareScreenButton.addEventListener("click", async () => { // Prompt the user to share their screen. stream = await navigator.mediaDevices.getDisplayMedia(); recorder = new MediaRecorder(stream); // Preview the screen locally. video.srcObject = stream; }); stopShareScreenButton.addEventListener("click", () => { // Stop the stream. stream.getTracks().forEach(track => track.stop()); video.srcObject = null; }); startRecordButton.addEventListener("click", async () => { // For the sake of more legible code, this sample only uses the // `showSaveFilePicker()` method. In production, you need to // cater for browsers that don't support this method, as // outlined in https://web.dev/articles/files/save-a-file/. // Prompt the user to choose where to save the recording file. const suggestedName = "screen-recording.webm"; const handle = await window.showSaveFilePicker({ suggestedName }); const writable = await handle.createWritable(); // Start recording. recorder.start(); recorder.addEventListener("dataavailable", async (event) => { // Write chunks to the file. await writable.write(event.data); if (recorder.state === "inactive") { // Close the file when the recording stops. await writable.close(); } }); }); stopRecordButton.addEventListener("click", () => { // Stop the recording. recorder.stop(); });` Browser support MediaDevices.getDisplayMedia() Browser Support 72 79 66 13 [Source](https://developer.mozilla.org/docs/Web/API/MediaDevices/getDisplayMedia) MediaRecorder API Browser Support 47 79 25 14.1 [Source](https://developer.mozilla.org/docs/Web/API/MediaRecorder) File System Access API's showSaveFilePicker() Browser Support 86 86 x x [Source](https://developer.mozilla.org/docs/Web/API/Window/showOpenFilePicker) Further reading [W3C Screen Capture Specification](https://w3c.github.io/mediacapture-screen-share/) [W3C MediaStream Recording Specification](https://w3c.github.io/mediacapture-record/#mediarecorder-api) [WICG File System Access Specification](https://wicg.github.io/file-system-access/) Demo [Open demo](/articles/media/screen-record/demo) Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2026-09-04 UTC.