Launching AR experiences
SDK Guide
Use the SDK to smoothly transition your users into Variant Launch as needed.
Embed the SDK
Add this script tag as the first item, or as early as possible in your <head>. It should run before your 3D engine code if you want WebXR support available when your other code runs.
<script src="https://launchar.app/sdk/v1?key=YOUR_SDK_KEY"></script>
For a page that should automatically send iOS visitors to the hosted Launch page, add &redirect=true.
Launch from a button
Enable your button once the SDK is initialized. Call VLaunch.launch() directly in the user's click handler to open the current page in Launch. Pass a URL to open an authorised destination instead.
launchButton.addEventListener('click', () => {
VLaunch.launch('https://yoursite.com/experience?room=2#sculpture')
})
The SDK handles the iOS route. Safari shows the Launch banner or card. Other iOS browsers try Safari and can open the native App Clip with the standard Variant card if the page stays active. The user may see a browser confirmation prompt. Keep the call in the click handler so the browser can associate the handoff with the tap.
Starting a WebXR AR Session
Before showing your AR button, check await navigator.xr?.isSessionSupported('immersive-ar'). Request the session when the user taps.
navigator.xr.requestSession('immersive-ar', {
requiredFeatures: ['local'],
})
Share a Launch link
Use the hosted link or QR code from your Launch dashboard when sharing an experience. To build a hosted link for a different destination in the current browser, use getLaunchUrl(targetURL).
const launchUrl = VLaunch.getLaunchUrl('https://yoursite.com/?room=2&lang=en#sculpture')
Direct App Clip URLs
The optional directAppClipUrl in the initialization event is for integrations that manage their own Apple App Clip invocation. It is valid for 30 minutes by default. Use VLaunch.launch() for your Launch button.
Tracking Quality Changes
Listen for vlaunch-ar-tracking on window. The Viewer reports normal in event.detail.status when tracking is ready.
window.addEventListener('vlaunch-ar-tracking', (event) => {
if (event.detail.status === 'normal') console.log('Tracking is ready')
})
Initialisation Event
If you want additional information and control, you can listen for the vlaunch-initialized event. Register the listener before loading the SDK script. If the event doesn’t fire, check your project key and authorised domain.
window.addEventListener('vlaunch-initialized', (event) => {
launchButton.hidden = !event.detail.launchRequired
launchButton.disabled = false
})
Here is the full payload sent with the 'vlaunch-initialized' event as event.detail:
{
launchRequired: boolean
webXRStatus: 'unsupported' | 'launch-required' | 'supported'
launchUrl: string
directAppClipUrl?: string
browser: string
platform: 'ios' | 'android' | 'desktop'
launchInstructions: string | null
}
launchRequired will be true if the user is on an iOS device where visiting the launch URL will enable WebXR. This value is false if the user is already in the Launch viewer.
webXRStatus indicates whether the browser has a WebXR API or needs the Viewer. Use isSessionSupported('immersive-ar') to check for AR support.
launchUrl points to the hosted Launch page for the current experience. For a button that opens a specific experience, pass its URL to VLaunch.launch(targetURL).
When present, directAppClipUrl contains a direct Apple App Clip URL for the current page. Use this only if you are handling the Safari handoff yourself.