How-to guides
Capture or choose a photo
Enable still-camera capture and a single-image library picker.
Enable capture
Apply the capability setup with this dependency and config:
pnpm add @capacitor/camera@8.2.6internalPlugins: { camera: true },
pluginOptions: {
Camera: {
usageDescription: "Take a photo to attach to your report.",
photoLibraryUsageDescription: "Choose a photo to attach to your report.",
},
},Connect actions
Connect these @akshatowo/radical/react hooks to user actions:
const camera = useCamera();
const permission = useCameraPermission();
// Buttons:
permission.request();
camera.capture();
camera.choose();
// After returning from settings:
permission.check();Show the image
Disable actions while camera.loading and render successful results:
<img src={camera.value.dataUrl} alt="Selected attachment" />You see the captured or selected photo.
Keep the hook mounted until the picker closes. Interruption cannot dismiss it.