File: XRButton.md | Updated: 11/15/2025
A utility class for creating a button that allows to initiate immersive XR sessions based on WebXR. The button can be created with a factory method and then appended ot the website's DOM.
Compared to ARButton and VRButton, this class will try to offer an immersive AR session first. If the device does not support this type of session, it uses an immersive VR session.
document.body.appendChild( XRButton.createButton( renderer ) );
XRButton is an addon, and must be imported explicitly, see Installation#Addons.
import { XRButton } from 'three/addons/webxr/XRButton.js';
Constructs a new XR button.
renderer | The renderer.
---|---
sessionInit | The a configuration object for the AR session.
Returns: The button or an error message if WebXR isn't supported.