This guide will help you get up and running with reticlexr in a few minutes.
Installation
Install the package from npm with your package manager:
npm install reticlexrThe package ships as plain ESM source; there is no build step and no transpilation. Its renderer/bridge dependencies are peer dependencies your app provides:
| Package | Version (from package.json) | Why |
|---|---|---|
@capacitor/core | ^8.5.2 | The Capacitor bridge the native facade registers with; any Capacitor 8 app already has it |
three | ^0.180.0 | The WebXR runtime's renderer, scene and GLTF loader |
react (>=16.8.0) is a peer dependency for the
useARCore hook, which lives at
reticlexr/react.
Note
The package root still re-exports useARCore as a deprecated
alias, so importing the root entry still pulls React in 1.x.
Framework-agnostic code can import the subpaths instead
(reticlexr/ar-view, reticlexr/web, reticlexr/gestures), which
never touch React.
Hand-written TypeScript declarations ship with the package
(src/*.d.ts), so TypeScript projects get full checking.
For a Capacitor app, install the package and sync:
npm install reticlexr
npx cap syncNote
The package's package.json carries the
"capacitor": { "android": { "src": "android" }, "ios": { "src": "ios" } }
metadata key, so
cap sync discovers and registers the native plugins automatically
(ARCorePlugin in the generated capacitor.plugins.json, a
:reticlexr project in the generated settings). No manual
settings.gradle edit is needed; the clean consumer flow is
verified in a scratch Capacitor app.
The native Android side, once wired, provides session management, hit testing and surface events through ARCore. Be aware of what it does not do yet: native model rendering is not implemented: models render in the WebXR runtime. Read WebXR vs native ARCore before planning an Android-native-only experience.
On iOS the native side is the whole experience (since 1.2.0): there is no WebXR in Safari/WKWebView, so the iOS plugin renders models itself with ARKit + RealityKit. See the iOS section at the end of this guide for its setup steps.
The high-level API is createARView(). It needs a DOM element to use as
the immersive session's overlay, your buttons and product UI live there.
What happens next is covered by the guides: React integration for component-shaped usage, Gestures for tap/pinch/twist, and Model preloading & switching for product catalogues.
Note
create() asks the browser for an immersive-ar session with the
hit-test feature required. local-floor is requested when
available, with local and viewer reference-space fallbacks, so
a device/browser without local-floor degrades instead of failing
session creation.
import { createARView } from 'reticlexr';
const ar = createARView({
overlay: document.querySelector('#ar-overlay'),
});
// Starts the WebXR session. Defaults shown; every option is optional.
await ar.create({
showReticle: true, // centre placement reticle
showPlaneDots: true, // dotted visualisation over detected planes
showShadow: true, // soft blob shadow under the model
planeDetection: false, // opt-in tier; the default session is hit-test only
lightEstimation: false, // opt-in tier
});
// Cache the parsed models so placement and switching are fast.
await ar.preloadModels(['/models/sofa.glb', '/models/chair.glb']);
// Places at the current centre hit test.
const result = await ar.placeModel('/models/sofa.glb');
if (!result.success) {
// result.code === 'NO_SURFACE' when no surface is in view yet
console.log('Keep scanning:', result.code);
}<div id="ar-overlay">
<!-- Buttons here are normal DOM. Mark interactive UI with data-ui so
the gesture layer ignores it. -->
<button data-ui onclick="...">Add to cart</button>
</div>WebXR immersive AR only runs in a secure context: HTTPS, or
localhost. A page served over plain HTTP on a LAN address will load, but
session creation will fail: checkSupport() reports
{ supported: false, code: 'INSECURE_CONTEXT' } in that case, so check
the code (and the URL scheme) first when AR refuses to start.
Zero-setup option
Open this site's live demo on the phone. It is served over HTTPS, so the only requirements are the device ones below.
Testing your own app on a phone
Requirements (from the repository's phone-testing guide):
- An ARCore-capable Android phone with Google Play Services for AR
- Current Chrome on the phone
- Phone and development computer on the same Wi-Fi
The example app ships LAN HTTPS tooling with a self-signed development CA:
cd example
npm install
npm run cert # generates a private dev CA + server cert for your LAN IP
npm run dev:https # serves https://<LAN-IP>:5173Then:
- Transfer only
example/certs/dev-ca.crtto the phone, never the.keyfile. - Install it as a CA certificate (Settings → Security → Encryption & credentials; exact wording varies by vendor).
- Restart Chrome on the phone.
- Open the printed
https://<LAN-IP>:5173URL, tap Start AR, grant camera access, and move the phone slowly over a textured floor or table until surface dots appear.
Tip
A self-signed certificate without the CA install also works for a quick look: Chrome will warn once per origin; choose Advanced → Proceed. Pages still count as secure contexts, so WebXR runs, but the warning returns on every new origin, which is why the CA flow is worth it for repeated testing.
Warning
The generated certificates are development-only and git-ignored. Remove the development CA from the phone when you finish testing, and never use these keys in production.
iOS
iOS Safari does not expose the immersive-ar WebXR flow this SDK's
browser runtime is built on — but since 1.2.0 you don't need it to:
the package ships a native iOS runtime (ARKit + RealityKit)
behind the same ARCore facade, and it renders models for real.
Setup for a Capacitor app:
npm install reticlexr
npx cap add ios # if the ios platform is not in your project yet
npx cap sync # discovers the iOS plugin from the capacitor.ios key
npx cap open ios # opens the app in XcodeThen:
-
Add the camera usage string to your iOS app's
Info.plist(ios/App/App/Info.plist). Without it, iOS denies camera access andstartSessionrejects withCAMERA_PERMISSION_DENIED:<key>NSCameraUsageDescription</key> <string>Used to place products in your space with augmented reality.</string> -
Use USDZ models. ARKit/RealityKit cannot load GLB. Either pass the iOS source explicitly —
ARCore.placeModel({ modelUrl: 'models/sofa.glb', usdzUrl: 'models/sofa.usdz' })— or ship a.usdzsibling next to each GLB (same folder, same base name) and iOS picks it up automatically. If neither exists,placeModelrejects withMODEL_FORMAT_UNSUPPORTED. -
Run on a real iPhone/iPad (iOS 15+, ARKit-capable) from Xcode. The iOS Simulator has no ARKit world tracking, so AR cannot start there;
checkSupport()reports it as unsupported.
On iOS you drive AR through the ARCore facade (the high-level
createARView/hook layers are WebXR-only): startSession,
hitTest, placeModel, setTransform, setMaterial,
moveModel, removeModel, getPlacedModels, clearModels,
stopSession, with the same events as the Android native plugin.