Skip to content

adamalfredsson/react-media-devices

Repository files navigation



📷
react-media-devices


npm i react-media-devices

Exports a handy useMediaDevices hook that utilizes the MediaDevice API to detect available media devices.

Usage

import React from "react";
import { useMediaDevices } from "react-media-devices";

const App = () => {
  const { devices } = useMediaDevices();

  return (
    <div>
      <h1>Devices</h1>
      <ul>
        {devices?.map((device) => (
          <li key={device.id}>{device.label}</li>
        ))}
      </ul>
    </div>
  );
};