use-screen-recorder

React hook for easily recording screen using MediaStream APIs.

Install

yarn add use-screen-recorder

Usage

import * as React from "react";

import useScreenRecorder from "use-screen-recorder";

const Example = () => {
  const {
    blobUrl,
    pauseRecording,
    resetRecording,
    resumeRecording,
    startRecording,
    status,
    stopRecording,
  } = useScreenRecorder();

  return (
    <div>
      <video src={blobUrl} />

      <small>Status: {status}</small>

      <button onClick={startRecording}>Start Recording</button>
      <button onClick={stopRecording}>Stop Recording</button>
      <button onClick={pauseRecording}>Pause Recording</button>
      <button onClick={resumeRecording}>Resume Recording</button>
      <button onClick={resetRecording}>Reset Recording</button>
    </div>
  );
};

Props

audio

A boolean value indicating if audio track should be added.

type: boolean
default: false

options

A MediaRecorderOptions object.

type: object
default: {}