files/en-us/web/api/webxr_device_api/lifecycle/index.md
{{DefaultAPISidebar("WebXR Device API")}}
In this guide, we'll get a birds-eye view of what's involved in creating and driving a WebXR application, without diving down to the code level in detail. This serves as preparation for the next few articles in these WebXR guides, which cover starting up and shutting down a WebXR session, geometry, simulating cameras, spatial tracking, and more.
Most applications using WebXR will follow a similar overall design pattern:
Check to see if the user's device and browser are both capable of presenting the XR experience you want to provide.
inline, immersive-vr, or immersive-ar, in order to determine whether or not the type of session you wish to provide is available.When the user requests the activation of WebXR functionality by engaging with the user interface enabled above, request an {{DOMxRef("XRSession")}} using the desired mode. This is done by calling {{DOMxRef("XRSystem/requestSession","navigator.xr.requestSession()")}}, again specifying the string indicating the mode you want to enable: inline, immersive-vr, or immersive-ar.
If the promise returned by requestSession() resolves, use the new {{domxref("XRSession")}} to manage the WebXR session for the duration of the WebXR experience. This will involve managing inputs, animations, and rendering.
requestAnimationFrame() callback should use the information provided about the objects located in the 3D world to render the frame using WebGL.When the time comes (such as when the user exits your app or navigates away from your site), end the XR session; otherwise, continue the loop until the user chooses to exit XR mode.