@solidnative-dev/camera

Validated camera permissions, device discovery, session lifecycle, serialized photo capture, and a Solid-owned native preview. The React Native adapter drives VisionCamera 5's Nitro API directly without loading VisionCamera's React hooks or components.

Installation#

sh
pnpm add @solidnative-dev/camera react-native-vision-camera react-native-nitro-modules react-native-nitro-image

Register CAMERA_PREVIEW_DESCRIPTOR in the descriptors passed to createNativeFabricHost.

Usage#

tsx
import {
  CAMERA_PREVIEW_DESCRIPTOR,
  CameraPreview,
  createReactNativeCameraService,
} from "@solidnative-dev/camera/react-native";
import {
  createCameraSessionEvent,
  createOwnedCameraSession,
} from "@solidnative-dev/camera/solid";

const camera = createReactNativeCameraService();
await camera.requestPermission();

const owned = createOwnedCameraSession(camera, {
  position: "back",
  onError: console.error,
});
const session = await owned.ready;
const latestSessionEvent = createCameraSessionEvent(session);

const photo = await session.capturePhoto({
  flashMode: "off",
  enableShutterSound: false,
});
console.log(photo.filePath, photo.width, photo.height);

<CameraPreview session={session} resizeMode="cover" style={{ height: 240 }} />;

Entrypoints#

ImportKey exports
@solidnative-dev/cameracreateCameraService, CameraService, CameraSession, CameraDevice, CameraPhoto, CameraPermission, CameraSessionEvent
@solidnative-dev/camera/react-nativecreateReactNativeCameraService, CameraPreview, CAMERA_PREVIEW_DESCRIPTOR, CAMERA_PREVIEW_RESOURCE_KIND
@solidnative-dev/camera/solidcreateOwnedCameraSession, createCameraSessionEvent, OwnedCameraSession

Behavior & platform notes#

  • Owner-scoped hardware lifetime: createOwnedCameraSession binds opening, lifecycle subscriptions, idempotent stop, and output disposal to the current Solid owner. CameraPreview separately binds native preview output retention to its own owner; a stopped session cannot be re-mounted.
  • Serialized photo capture: Captures run one at a time, finish before teardown, and immediately dispose the in-memory Nitro Photo after writing a temporary file. Callers own copying or deleting the returned photo.filePath.
  • Zero React wrapper evaluation: Installs NitroModules directly through the narrow TurboModule registry and passes the preview output as an opaque JSI host resource into VisionCamera's generated PreviewView Fabric component.
  • Privacy-safe telemetry: Lifecycle transitions emit platform.camera.session.* default-priority causal events without recording device IDs, interruption reasons, or native error payloads.
  • Scope: Covers permissions, live preview, and still photo capture. Video recording, frame processors, and gallery persistence are not included.