The read-only id property on a MediaStream is a 36-character unique identifier (GUID) for that stream object. Learn the MDN getUserMedia example, UUID-style format checks, storing streams in a Map by id, how stream.id differs from track.id, and a permission-free canvas.captureStream() demo—with five examples and try-it labs.
01
Kind
Instance property
02
Returns
String GUID
03
Read-only
no setter
04
Length
36 characters
05
Use case
Lookup key
06
Status
Baseline widely
Fundamentals
Introduction
Every MediaStream object the browser creates gets its own id—a string you can read but never change. You receive streams from getUserMedia(), captureStream(), WebRTC, and similar APIs; each new stream carries a fresh id.
MDN describes id as a 36-character GUID (globally unique identifier). In practice it looks like a UUID with hyphens, for example f47ac10b-58cc-4372-a567-0e02b2c3d479. Use it to label streams in logs, store them in a Map, or tell two camera feeds apart in a multi-stream app.
💡
Beginner tip
id identifies the stream object, not the camera hardware. Two getUserMedia calls give two different ids even if they use the same physical webcam.
Concept
Understanding the id Property
A read-only instance property on MediaStream that holds the stream’s unique string identifier.
Type — string.
Read-only — you cannot assign to stream.id.
Length — 36 characters (MDN).
Format — GUID / UUID-style with hyphens.
Unique — each MediaStream instance gets its own id.
Typical read — right after getUserMedia() resolves.
Baseline Widely available on MDN (since September 2017).
Foundation
📝 Syntax
Read id on any MediaStream object:
JavaScript
mediaStream.id
Return value
A string: the unique identifier for this MediaStream (36 characters per MDN).
MediaStream.id is marked Baseline Widely available on MDN (since September 2017). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
MediaStream.id
Read-only 36-character GUID string—unique per MediaStream object.
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerNo MediaStream.id
Not supported
MediaStream.idExcellent
Bottom line: Read stream.id to identify, log, or index MediaStream objects in your app.
Wrap Up
Conclusion
MediaStream.id is a read-only string—a 36-character GUID that uniquely identifies one MediaStream object. Read it after getUserMedia(), use it as a Map key, and remember that each track has its own separate id.