TrustNXTTrustNXT
React SDKAPI ReferenceFunctions

useDeviceOrientation()

function useDeviceOrientation(onOrientationChange?): number;

Tracks the device's physical orientation angle (0, 90, 180, 270).

Listens to screen.orientation, the legacy orientationchange event, and resize as a fallback. Returns the current angle and optionally fires a callback (e.g., capture.setOrientation) on every change.

Parameters

ParameterTypeDescription
onOrientationChange?(angle) => voidOptional callback invoked with the new angle

Returns

number

Current orientation in degrees (0 | 90 | 180 | 270)

Example

const capture = useCapture({ mode: "image", apiKey: "..." });
const orientation = useDeviceOrientation(capture.setOrientation);

On this page