@threlte/xr

<XRButton>

<XRButton /> is an HTML <button /> that can be used to init a WebXR session. It will also display info about XR session browser support.

This is aliased by the more commonly used ARButton and VRButton which provide sensible session defaults.

Component Signature

Props

name
type
required
description

mode
'inline' | 'immersive-vr' | 'immersive-ar'
yes
The type of XRSession to create.

force
'enter' | 'exit'
no
Whether this button should only enter / exit an `XRSession`. Default is to toggle both ways

sessionInit
XRSessionInit
no
XRSession configuration options.

Events

name
payload
description

click
CustomEvent<'unsupported' | 'insecure' | 'blocked' | 'supported'>
Fired when a user clicks the VR button.

error
CustomEvent<Error>
Fired when an enter / exit session error occurs.