# Camera

VisionCamera previews, permissions, and automatic native compatibility patches.

Source: https://legend.so/spark/camera/

`@legendapp/spark/camera` exposes VisionCamera components, device/permission hooks, photo/video outputs, and session APIs with upstream semantics. It also exports `NitroImage` and its `Image` type. Advanced APIs remain available from `react-native-vision-camera` directly.

## [Camera preview](https://legend.so/spark/camera/#camera-preview)

```tsx
import {
  Camera, useCameraDevices, useCameraPermission, usePhotoOutput,
} from '@legendapp/spark/camera';
import { Button } from 'react-native';

export function PhotoCamera() {
  const devices = useCameraDevices();
  const { hasPermission, requestPermission } = useCameraPermission();
  const photoOutput = usePhotoOutput({ containerFormat: 'jpeg' });

  if (!hasPermission) {
    return <Button title="Allow camera" onPress={() => void requestPermission()} />;
  }
  return devices[0] ? <Camera device={devices[0]} isActive outputs={[photoOutput]} /> : null;
}
```

## [Installation and permissions](https://legend.so/spark/camera/#installation-and-permissions)

Spark installs VisionCamera 5.2.3, Nitro Image 0.15.2, and Nitro Modules 0.37.0. Compatibility patches apply automatically, including when install scripts were disabled. No separate camera install is needed. Production builds can remove unused camera code.

iOS and Android use upstream implementations; Spark adds macOS 14+ AppKit patches. Windows and web are unsupported. Live capture and mobile acceptance remain unverified; see the [prototype evidence and limits](https://github.com/LegendApp/legend-spark/blob/main/docs/camera-prototype.md).

On macOS, set `NSCameraUsageDescription` in `desktop.config.json` under `macos.infoPlist`; audio recording also needs `NSMicrophoneUsageDescription`. Set iOS usage descriptions and Android permissions through Expo/native configuration. Ask for permission when the user starts using the camera.

See Spark's [camera integration](https://github.com/LegendApp/legend-spark/blob/main/docs/camera.md) for imperative APIs, resource lifetimes, and patch details.

[View Markdown](https://legend.so/spark/camera.md)[Report a documentation correction](https://github.com/LegendApp/legend-docs/issues/new?title=Docs%3A+Camera&body=Page%3A+https%3A%2F%2Flegend.so%2Fspark%2Fcamera%0A%0AWhat+is+incorrect+or+missing%3F%0A%0AExpected+behavior+or+supporting+source%3A%0A)
