
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
react-mic-cam-permissions
Advanced tools
React-Mic-Cam-Permissions is a React library for managing camera and microphone permissions in web applications. It allows users to request and manage permissions seamlessly, while displaying status messages to inform the user of the results.
To install the library, run the following command:
npm i react-mic-cam-permissions
You can use the MicrophonePermissionButton component to request permission to use the microphone. Just add it to your component and pass the events to find out if permission was granted or denied.
import React from 'react';
import { MicrophonePermissionButton } from 'media-permissions';
const App = () => {
const handleGranted = () => {
console.log('Microphone permission granted');
};
const handleDenied = () => {
console.log('Microphone permission denied');
};
return (
<div>
<h1>Microphone Permission</h1>
<MicrophonePermissionButton
buttonText="Request Microphone Permission"
onGranted={handleGranted}
onDenied={handleDenied}
/>
</div>
);
};
export default App;
The CameraPermissionButton component works the same as the one for the microphone, but for the camera.
import React from 'react';
import { CameraPermissionButton } from 'media-permissions';
const App = () => {
const handleGranted = () => {
console.log('Camera permission granted');
};
const handleDenied = () => {
console.log('Camera permission denied');
};
return (
<div>
<h1>Camera Permission</h1>
<CameraPermissionButton
buttonText="Request Camera Permission"
onGranted={handleGranted}
onDenied={handleDenied}
/>
</div>
);
};
export default App;
The PermissionStatus component allows you to display the current status of permissions for the camera or microphone, with icons adapted to indicate whether the permission has been granted, denied, or is pending.
import React from 'react';
import { PermissionStatus } from 'media-permissions';
const App = () => {
return (
<div>
<h1>Permission Status</h1>
<PermissionStatus permissionType="microphone" state="granted" />
<PermissionStatus permissionType="camera" state="denied" />
</div>
);
};
export default App;
You can also display available devices (cameras and microphones) and allow users to select them using the PermissionStatusDisplay component.
import React from 'react';
import { PermissionStatusDisplay } from 'media-permissions';
const App = () => {
return (
<div>
<h1>Media Permissions</h1>
<PermissionStatusDisplay />
</div>
);
};
export default App;
You can also manage permissions directly with the useCameraPermission and useMicrophonePermission hooks.
import React, { useEffect } from 'react';
import { useMicrophonePermission } from 'media-permissions';
const App = () => {
const { permissionState, requestPermission } = useMicrophonePermission();
useEffect(() => {
console.log('Microphone permission state:', permissionState);
}, [permissionState]);
return (
<div>
<h1>Microphone Permission</h1>
<button onClick={requestPermission}>Request Microphone Permission</button>
<p>Current Permission State: {permissionState}</p>
</div>
);
};
export default App;
import React, { useEffect } from 'react';
import { useCameraPermission } from 'media-permissions';
const App = () => {
const { permissionState, requestPermission } = useCameraPermission();
useEffect(() => {
console.log('Camera permission state:', permissionState);
}, [permissionState]);
return (
<div>
<h1>Camera Permission</h1>
<button onClick={requestPermission}>Request Camera Permission</button>
<p>Current Permission State: {permissionState}</p>
</div>
);
};
export default App;
PermissionStatus component allows you to display the permission status.useCameraPermission and useMicrophonePermission hooks.MicrophonePermissionButtonclassName: Customizes the style of the button.buttonText: The text to display on the button.onGranted: Callback when permission is granted.onDenied: Callback when permission is denied.CameraPermissionButtonWorks the same as MicrophonePermissionButton, but for the camera.
PermissionStatuspermissionType: Can be camera or microphone.state: The state of the permission, can be granted, denied, prompt or unavailable.className: Customizes the display style.PermissionStatusDisplayDisplays a set of controls for managing permissions and selecting devices.
useMicrophonePermissionReturns the permission status for the microphone as well as a function to request this permission.
useCameraPermissionReturns the permission status for the camera as well as a function to request this permission.
FAQs
Managing camera and microphone permissions with React
The npm package react-mic-cam-permissions receives a total of 25 weekly downloads. As such, react-mic-cam-permissions popularity was classified as not popular.
We found that react-mic-cam-permissions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.