{"id":13880827,"url":"https://github.com/DeltaCircuit/react-media-recorder","last_synced_at":"2025-07-16T17:31:08.306Z","repository":{"id":37925185,"uuid":"132737562","full_name":"DeltaCircuit/react-media-recorder","owner":"DeltaCircuit","description":"react-media-recorder is a react component with render prop that can be used to record audio/video streams using MediaRecorder API.","archived":false,"fork":false,"pushed_at":"2024-09-04T04:15:03.000Z","size":122,"stargazers_count":552,"open_issues_count":67,"forks_count":137,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-09T12:52:08.862Z","etag":null,"topics":["audio-recorder","getdisplaymedia","getusermedia","media-recording","mediarecorder","react","record-audio","record-video","recorder","screen-recorder","video-recorder","video-recording","voice-recording"],"latest_commit_sha":null,"homepage":"https://npmjs.com/react-media-recorder","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeltaCircuit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-05-09T09:59:27.000Z","updated_at":"2025-07-04T02:11:36.000Z","dependencies_parsed_at":"2023-08-29T03:21:25.915Z","dependency_job_id":"83dc9ff6-81c1-44c4-a5d5-e1de02946d1c","html_url":"https://github.com/DeltaCircuit/react-media-recorder","commit_stats":null,"previous_names":["giridharangm/react-media-recorder","deltacircuit/react-media-recorder","0x006f/react-media-recorder"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/DeltaCircuit/react-media-recorder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeltaCircuit%2Freact-media-recorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeltaCircuit%2Freact-media-recorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeltaCircuit%2Freact-media-recorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeltaCircuit%2Freact-media-recorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeltaCircuit","download_url":"https://codeload.github.com/DeltaCircuit/react-media-recorder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeltaCircuit%2Freact-media-recorder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264567181,"owners_count":23629341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio-recorder","getdisplaymedia","getusermedia","media-recording","mediarecorder","react","record-audio","record-video","recorder","screen-recorder","video-recorder","video-recording","voice-recording"],"created_at":"2024-08-06T08:03:31.571Z","updated_at":"2025-07-16T17:31:08.273Z","avatar_url":"https://github.com/DeltaCircuit.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# react-media-recorder :o2: :video_camera: :microphone: :computer:\n\n`react-media-recorder` is a fully typed react component with render prop, or a react hook, that can be used to:\n\n- Record audio/video\n- Record screen\n\nusing [MediaRecorder API](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder).\n\n## Installation\n\n```\nnpm i react-media-recorder\n```\n\nor\n\n```\nyarn add react-media-recorder\n```\n\n## Usage\n\n```javascript\nimport { ReactMediaRecorder } from \"react-media-recorder\";\n\nconst RecordView = () =\u003e (\n  \u003cdiv\u003e\n    \u003cReactMediaRecorder\n      video\n      render={({ status, startRecording, stopRecording, mediaBlobUrl }) =\u003e (\n        \u003cdiv\u003e\n          \u003cp\u003e{status}\u003c/p\u003e\n          \u003cbutton onClick={startRecording}\u003eStart Recording\u003c/button\u003e\n          \u003cbutton onClick={stopRecording}\u003eStop Recording\u003c/button\u003e\n          \u003cvideo src={mediaBlobUrl} controls autoPlay loop /\u003e\n        \u003c/div\u003e\n      )}\n    /\u003e\n  \u003c/div\u003e\n);\n```\n\nSince `react-media-recording` uses render prop, you can define what to render in the view. Just don't forget to wire the `startRecording`, `stopRecording` and `mediaBlobUrl` to your component.\n\n## Usage with react hooks\n\n```javascript\nimport { useReactMediaRecorder } from \"react-media-recorder\";\n\nconst RecordView = () =\u003e {\n  const { status, startRecording, stopRecording, mediaBlobUrl } =\n    useReactMediaRecorder({ video: true });\n\n  return (\n    \u003cdiv\u003e\n      \u003cp\u003e{status}\u003c/p\u003e\n      \u003cbutton onClick={startRecording}\u003eStart Recording\u003c/button\u003e\n      \u003cbutton onClick={stopRecording}\u003eStop Recording\u003c/button\u003e\n      \u003cvideo src={mediaBlobUrl} controls autoPlay loop /\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\nThe hook receives an object as argument with the same ReactMediaRecorder options / props (except the `render` function).\n\n### Options / Props\n\n#### audio\n\nCan be either a boolean value or a [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) object.\n\ntype: `boolean` or `object`  \ndefault: `true`\n\n#### blobPropertyBag\n\n[From MDN](https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob):  \nAn optional `BlobPropertyBag` dictionary which may specify the following two attributes (for the `mediaBlob`):\n\n- `type`, that represents the MIME type of the content of the array that will be put in the blob.\n- `endings`, with a default value of \"transparent\", that specifies how strings containing the line ending character \\n are to be written out. It is one of the two values: \"native\", meaning that line ending characters are changed to match host OS filesystem convention, or \"transparent\", meaning that endings are stored in the blob without change\n\ntype: `object`  \ndefault:  \nif `video` is enabled,\n\n```\n{\n   type: \"video/mp4\"\n}\n```\n\nif there's only `audio` is enabled,\n\n```\n{\n  type: \"audio/wav\"\n}\n```\n\n#### customMediaStream  \n\nA media stream object itself (optional)\n\n#### mediaRecorderOptions\n\nAn optional options object that will be passed to `MediaRecorder`. Please note that if you specify the MIME type via either `audio` or `video` prop _and_ through this `mediaRecorderOptions`, the `mediaRecorderOptions` have higher precedence.\n\ntype: `object`  \ndefault: `{}`\n\n#### onStart\n\nA `function` that would get invoked when the MediaRecorder starts.\n\ntype: `function()`  \ndefault: `() =\u003e null`\n\n#### onStop\n\nA `function` that would get invoked when the MediaRecorder stops. It'll provide the blob and the blob url as its params.\n\ntype: `function(blobUrl: string, blob: Blob)`  \ndefault: `() =\u003e null`  \n\n#### stopStreamsOnStop\n\nWhether to stop all streams on stop. By default, its `true`\n\n#### render\n\nA `function` which accepts an object containing fields: `status`, `startRecording`, `stopRecording` and`mediaBlob`. This function would return a react element/component.\n\ntype: `function`  \ndefault: `() =\u003e null`\n\n#### screen\n\nA `boolean` value. Lets you to record your current screen. Not all browsers would support this. Please [check here](https://caniuse.com/#search=getDisplayMedia) for the availability. Please note that at the moment, the MediaRecorder won't record two alike streams at a time, if you provide both `screen` and `video` prop, the **screen capturing will take precedence** than the video capturing. But, you can provide the `video` prop (_as the MediaTrackConstraints_) which will then utilized by screen capture (for example, `height`, `width` etc..)\n\n#### video\n\nCan be either a boolean value or a [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) object.\n\ntype: `boolean` or `object`  \ndefault: `false`\n\n#### askPermissionOnMount\n\nA boolean value. If set to `true`, will ask media permission on mounting.\n\ntype: `boolean`\ndefault: `false`\n\n### Props available in the `render` function\n\n#### error\n\nA string enum. Possible values:\n\n- `media_aborted`\n- `permission_denied`\n- `no_specified_media_found`\n- `media_in_use`\n- `invalid_media_constraints`\n- `no_constraints`\n- `recorder_error`\n\n#### status\n\nA string `enum`. Possible values:\n\n- `media_aborted`\n- `permission_denied`\n- `no_specified_media_found`\n- `media_in_use`\n- `invalid_media_constraints`\n- `no_constraints`\n- `recorder_error`\n- `idle`\n- `acquiring_media`\n- `recording`\n- `stopping`\n- `stopped`\n\n#### startRecording\n\nA `function`, which starts recording when invoked.\n\n#### pauseRecording\n\nA `function`, which pauses the recording when invoked.\n\n#### resumeRecording\n\nA `function`, which resumes the recording when invoked.\n\n#### stopRecording\n\nA `function`, which stops recording when invoked.\n\n#### muteAudio\n\nA `function`, which mutes the audio tracks when invoked.\n\n#### unmuteAudio\n\nA `function` which unmutes the audio tracks when invoked.\n\n#### mediaBlobUrl\n\nA `blob` url that can be wired to an `\u003caudio /\u003e`, `\u003cvideo /\u003e` or an `\u003ca /\u003e` element.\n\n#### clearBlobUrl\n\nA `function` which clears the existing generated blob url (if any) and resets the workflow to its initial `idle` state.\n\n#### isMuted\n\nA boolean prop that tells whether the audio is muted or not.\n\n#### previewStream\n\nIf you want to create a live-preview of the video to the user, you can use this _stream_ and attach it to a `\u003cvideo /\u003e` element. Please note that this is a **muted stream**. This is by design to get rid of internal microphone feedbacks on machines like laptop.\n\nFor example:\n\n```tsx\nconst VideoPreview = ({ stream }: { stream: MediaStream | null }) =\u003e {\n  const videoRef = useRef\u003cHTMLVideoElement\u003e(null);\n\n  useEffect(() =\u003e {\n    if (videoRef.current \u0026\u0026 stream) {\n      videoRef.current.srcObject = stream;\n    }\n  }, [stream]);\n  if (!stream) {\n    return null;\n  }\n  return \u003cvideo ref={videoRef} width={500} height={500} autoPlay controls /\u003e;\n};\n\nconst App = () =\u003e (\n  \u003cReactMediaRecorder\n    video\n    render={({ previewStream }) =\u003e {\n      return \u003cVideoPreview stream={previewStream} /\u003e;\n    }}\n  /\u003e\n);\n```\n\n#### previewAudioStream\n\nIf you want access to the live audio stream for use in sound visualisations, you can use this _stream_ as your audio source and extract data from it using the [AudioContext](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext) and [AnalyzerNode](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode) features of the Web Audio API. Some javascript examples of how to do this can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API).\n\n## Contributing\n\nFeel free to submit a PR if you found a bug (I might've missed many! :grinning:) or if you want to enhance it further.\n\nThanks!. Happy Recording!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDeltaCircuit%2Freact-media-recorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDeltaCircuit%2Freact-media-recorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDeltaCircuit%2Freact-media-recorder/lists"}