@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-imageRegister 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#
| Import | Key exports |
|---|---|
@solidnative-dev/camera | createCameraService, CameraService, CameraSession, CameraDevice, CameraPhoto, CameraPermission, CameraSessionEvent |
@solidnative-dev/camera/react-native | createReactNativeCameraService, CameraPreview, CAMERA_PREVIEW_DESCRIPTOR, CAMERA_PREVIEW_RESOURCE_KIND |
@solidnative-dev/camera/solid | createOwnedCameraSession, createCameraSessionEvent, OwnedCameraSession |
Behavior & platform notes#
- Owner-scoped hardware lifetime:
createOwnedCameraSessionbinds opening, lifecycle subscriptions, idempotent stop, and output disposal to the current Solid owner.CameraPreviewseparately 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
Photoafter writing a temporary file. Callers own copying or deleting the returnedphoto.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
PreviewViewFabric 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.