WebXR & Mobile AR
Aircada's WebXR hooks abstract Android Chrome immersive-ar sessions and iOS Safari USDZ QuickLook fallbacks behind a unified React lifecycle.
useAirXR Hook & 6DoF WebXR Spatial Tracking | Aircada Docs#
Cross-Platform AR Launch Pipeline
useAirXR() inspects browser XR support at runtime and exposes a single launchAR(options?) entry point. On Android Chrome devices supporting W3C immersive-ar with hit-testing, it mounts an in-browser WebXR session with a DOM overlay. On iOS Safari devices without WebXR, it routes automatically to an exported .usdz endpoint for native Apple AR QuickLook.
Hit-Testing & Tracking States
During active WebXR sessions, useAirXR exposes currentSurface (XRHitSurface) and trackingState (XRTrackingState) so UI overlays can display placement reticles, floor-vs-wall normal alignment feedback, standoff offsets, and tracking recovery prompts while users scan their physical environment.
Deployment Constraints
WebXR requires a secure HTTPS context; testing over plain http:// reports isAvailable: false. When targeting iOS QuickLook fallback, ensure the project provides a pre-exported .usdz asset or uses Aircada's runtime USDZ export pipeline.
| Member | Type | Description |
|---|---|---|
| isARActive | boolean | True while an immersive WebXR session is running. |
| currentSurface | XRHitSurface | null | Latest raycast hit plane and surface normal from WebXR. |
| trackingState | XRTrackingState | Current 6DoF SLAM tracking quality status. |
| launchAR(options?) | (options?: XRLaunchOptions) => Promise<void> | Starts immersive-ar or triggers iOS QuickLook USDZ fallback. |
| stopAR() | () => Promise<void> | Ends the active XR session and restores the standard viewport. |
import { useAirXR } from "@aircada/react";
export function ArLaunchButton() {
const { isARActive, trackingState, currentSurface, launchAR, stopAR } = useAirXR();
return (
<button onClick={() => (isARActive ? stopAR() : launchAR())}>
{isARActive ? `Exit AR (${trackingState})` : currentSurface ? "Place in Room" : "View in AR"}
</button>
);
}