MediaStream.removeTrack(track) removes a MediaStreamTrack from the stream’s track set. Per MDN, it returns undefined — it does not stop the track’s media source.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call stream.removeTrack. Start with this line.
JavaScript
mediaStream.removeTrack(track)
Call
What it does
mediaStream.removeTrack(track)
Primary signature.
stream.removeTrack(...)
Call with the arguments your case needs.
Built into the browser. Call removeTrack(...) on a MediaStream — no import required.
Library declarations
JavaScript
mediaStream.removeTrack(track)
Parameters
Parameter
Description
track
Required. MediaStreamTrack to remove
Return Value
Return Value
Description
*
Always undefined
JavaScript Examples
Example 1 — Basic removeTrack()
Add a canvas track, then remove it so the stream is empty.
Create track B. From a different capture — not in A.
Call removeTrack(B). B was never in A.
Length stays 1. Quiet no-op, no throw.
Compatibility
Browser Support
MediaStream.removeTrack() is Baseline Widely available (MDN: since September 2017). 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 removing tracks from a stream.
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
removeTrack()Excellent
Bottom line: Browser only — not a Node.js API. Safe for production. Use it to detach tracks; pair with track.stop() when you also need to end the source.
Frequently Asked Questions
removeTrack(track) removes a MediaStreamTrack from the stream’s track set. Pass the track object that is currently in the stream.
No. MDN marks MediaStream.removeTrack() as Baseline Widely available (since September 2017). It is not Deprecated, Experimental, or Non-standard.
undefined. MDN documents no return value. Use getTracks() afterward to see what remains.
No. It only detaches the track from this stream. Call track.stop() separately if you want to end the camera or microphone hardware.
addTrack(track) adds a track to the stream. removeTrack(track) removes it. They are inverse operations for composing streams.
The call is a no-op — the track set is unchanged and it does not throw.