The removetrack event fires on a MediaStream when a MediaStreamTrack has been removed. Per MDN, it is a MediaStreamTrackEvent, is not cancelable, and does not bubble.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for removetrack. Start with this line.
JavaScript
stream.addEventListener("removetrack", handler)
Call
What it does
stream.addEventListener("removetrack", handler)
Primary signature.
Built into the browser. Listen with stream.addEventListener("removetrack", …) — no import required.
Library declarations
JavaScript
stream.addEventListener("removetrack", handler)
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
Fires as a MediaStreamTrackEvent (listener receives the event).
JavaScript Examples
Example 1 — addEventListener("removetrack")
Listen first, then remove a canvas video track (MDN pattern).
removeTrack does not stop the track — call track.stop() separately if needed.
Compatibility
Browser Support
The removetrack event is Baseline Widely available (MDN: since July 2020). It is part of the Media Capture and Streams specification. It is a browser Web API — not available in Node.js, Bun, or Deno.
✓ Baseline · Widely available
MediaStream: removetrack
Supported across modern Chrome, Firefox, Safari, and Edge for track-removed notifications.
98%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
removetrackExcellent
Bottom line: Browser only — not a Node.js API. Safe for production. Prefer addEventListener("removetrack", …) when you may need more than one listener. See the MDN removetrack reference.
Frequently Asked Questions
When a MediaStreamTrack is removed from a MediaStream — for example after calling removeTrack(track) on that stream when the track was present.
No. MDN marks the removetrack event as Baseline Widely available (since July 2020). It is not Deprecated, Experimental, or Non-standard.
A MediaStreamTrackEvent. It inherits from Event and includes a read-only track property with the MediaStreamTrack that was removed.
No. MDN says the event is not cancelable and does not bubble.
removeTrack() is the method that detaches a track from the stream. removetrack is the event that fires after a track has been removed — listen with addEventListener or onremovetrack.
addtrack fires when a track is added to a MediaStream — for example after addTrack(track). It is the counterpart to removetrack.