WebXR & Mobile AR

Published Updated
React hooks and cross-platform routing for 6DoF WebXR hit-testing and iOS QuickLook 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#

Manages cross-platform WebXR hit-testing, 6DoF tracking state, and iOS QuickLook USDZ fallbacks.

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.

UseAirXRReturn API Surface
MemberTypeDescription
isARActivebooleanTrue while an immersive WebXR session is running.
currentSurfaceXRHitSurface | nullLatest raycast hit plane and surface normal from WebXR.
trackingStateXRTrackingStateCurrent 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.
ArLaunchButton.tsx (tsx)
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>
  );
}
Launch WebXR on Android or QuickLook USDZ on iOS using useAirXR.