browser-permissions-helper v4.1.5
Browser Permissions Helper
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.
š Features
- ā Check the current permission status for various browser APIs.
- š Request permissions dynamically.
- š¢ Handle permission changes efficiently.
- šÆ Lightweight and easy to integrate.
š¦ Installation
npm install browser-permissions-helper
or
yarn add browser-permissions-helper
š Usage
Import the Module
import { PermissionType, checkPermission, requestPermission } from 'browser-permissions-helper';
Check Permission Status
const status = await checkPermission(PermissionType.Geolocation);
console.log(`Geolocation permission: ${status}`);
Request Permission
const result = await requestPermission(PermissionType.Notifications);
console.log(`Notification permission granted: ${result}`);
š Supported Permissions
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
š API Reference
checkPermission(permissionType: PermissionType) => Promise<'granted' | 'denied' | 'prompt'>
Checks the current status of a given permission.
requestPermission(permissionType: PermissionType) => Promise<boolean>
Requests the specified permission from the user and returns true
if granted, otherwise false
.
š”ļø Browser Compatibility
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) |
š¤ Contributing
Contributions are welcome! Feel free to fork the repository, create a feature branch, and submit a PR.
š License
This project is licensed under the MIT License.
š¬ Contact
For any queries or issues, please open an issue.
ā If you find this package useful, consider giving it a star on GitHub! ā
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago