A simple utility to manage and request browser permissions seamlessly. This package provides an easy-to-use API for handling permissions like notifications, geolocation, camera, microphone, and more.
- β Check the current permission status for various browser APIs.
- π Request permissions dynamically.
- π’ Handle permission changes efficiently.
- π― Lightweight and easy to integrate.
npm install browser-permissions-helper
or
yarn add browser-permissions-helper
import {
PermissionType,
checkPermission,
requestPermission,
getPermissionSupportInfo
} from 'browser-permissions-helper';
const status = await checkPermission(PermissionType.Geolocation);
console.log(`Geolocation permission: ${status}`);
const result = await requestPermission(PermissionType.Notifications);
console.log(`Notification permission granted: ${result}`);
const info = getPermissionSupportInfo(PermissionType.Bluetooth);
console.log(info.supportedBrowsers); // ['Chrome', 'Edge']
console.log(info.notes); // 'Not supported in Firefox or Safari'
geolocation
clipboard-write
notifications
camera
microphone
camera-advanced
speaker-selection
bluetooth
midi
nfc
screen-wake-lock
persistent-storage
push
idle-detection
storage-access
display-capture
window-management
Checks the current status of a given permission.
Requests the specified permission from the user and returns true
if granted, otherwise false
.
getPermissionSupportInfo(permissionType: PermissionType) => { supportedBrowsers: string[]; notes?: string; }
Returns a list of browsers that support the given permission, with optional notes for caveats or limited support.
This package works in modern browsers that support the Permissions API.
Browser | Supported |
---|---|
Chrome | β Yes |
Firefox | β Yes |
Edge | β Yes |
Safari | β Partial (Some permissions may not be available) |
π‘ Use
getPermissionSupportInfo()
to programmatically check support for specific permission.
Contributions are welcome! Feel free to fork the repository, create a feature branch, and submit a PR.
This project is licensed under the MIT License.
For any queries or issues, please open an issue.
β If you find this package useful, consider giving it a star on GitHub! β