--- title: useRequestPermissions description: >- The `useRequestPermissions` hook provides a function to request native device permissions from the user. It handles both app-level and system-level permission requests, showing appropriate dialogs and managing permission state. Supported permissions include camera, microphone, and device motion access. > Note: Before using this hook, add the required permissions to your Mini's manifest file: `"permissions": ["CAMERA"]`. api_name: shop-minis source_url: html: 'https://shopify.dev/docs/api/shop-minis/hooks/util/userequestpermissions' md: 'https://shopify.dev/docs/api/shop-minis/hooks/util/userequestpermissions.md' --- # use​Request​Permissions The `useRequestPermissions` hook provides a function to request native device permissions from the user. It handles both app-level and system-level permission requests, showing appropriate dialogs and managing permission state. Supported permissions include camera, microphone, and device motion access. **Note:** Before using this hook, add the required permissions to your Mini\'s manifest file: \\\"permissions\": \[\"C\A\M\E\R\A\"]\\. ## use​Request​Permissions() ### Returns * **UseRequestPermissionsReturns** ### ### UseRequestPermissionsReturns * **requestPermission** **(params: RequestPermissionParams) => Promise\** Request native permissions from the user ### UseRequestPermissionsReturns * requestPermission Request native permissions from the user ```ts (params: RequestPermissionParams) => Promise ``` ```ts interface UseRequestPermissionsReturns { /** * Request native permissions from the user */ requestPermission: ( params: RequestPermissionParams ) => Promise } ``` ### RequestPermissionParams * permission ```ts MiniPermission ``` ```ts export interface RequestPermissionParams { permission: MiniPermission } ``` ### MiniPermission ```ts 'CAMERA' | 'MICROPHONE' | 'MOTION' ``` ### RequestPermissionResponse * errorMessage ```ts string ``` * granted ```ts boolean ``` ```ts export interface RequestPermissionResponse { granted: boolean errorMessage?: string } ``` Examples ### Examples * #### Example code ##### Default ```tsx import {useRequestPermissions, Button} from '@shopify/shop-minis-react' export default function MyComponent() { const {requestPermission} = useRequestPermissions() const handleCameraPermission = async () => { try { const response = await requestPermission({permission: 'CAMERA'}) if (response.granted) { console.log('Camera permission granted') // You can now proceed with camera functionality } else { console.log('Camera permission denied:', response.errorMessage) // Handle the denial gracefully // For example: show alternative UI or functionality } } catch (error) { console.error('Failed to request camera permission:', error) // Handle unexpected errors } } return (
) } ```