Page Summary
-
Setting up a WebXR AR development environment requires a web server serving resources in a secure context and a WebXR-compatible browser on an ARCore-supported device.
-
A secure context, which ensures a certain level of security for web resources, is necessary for a trusted XR experience and requires resources to be delivered over TLS (
https://) or requested throughlocalhostor*.localhost. -
Port forwarding through Chrome DevTools can be used as an alternative to a TLS development server to serve resources in a secure context from a development machine to an Android device.
-
AR experiences on Android can only run on an ARCore-supported device with Google Play Services for AR installed and enabled.
To setup an environment capable of AR development using WebXR, you'll need:
- A web server that serves resources in a secure context
Use a secure context
A secure context is a security mechanism that ensures that web resources have been transferred with a certain level of security. You'll need a secure context to provide a trusted XR experience with your new features.
In other to qualify as being served in a secure context, your resource must meet at least one of the following conditions:
- The resource must be delivered over TLS (
https://) - The resource must be requested through
localhostor*.localhost.
Set up port forwarding
If you don't have a development server accessible over TLS, you can still develop in a secure context by using Chrome DevTools' Port forwarding . Port forwarding enables an Android device to access content hosted on the development machine's web server. It creates a listening TCP port on the Android device that maps to a TCP port on the development machine. Traffic can then travel through the USB connection between these two ports.
Follow these steps to set up port forwarding:
- Follow the steps for Set up port forwardingin the Chrome DevTools instructions .
- Ensure that the web server on the development workstation is running.
- Verify that your connection works. Open Google Chrome on the Android device and browse to
localhoston the port number specified in Port forwarding settings , for example,localhost:8000.
The resources on the web server should now be visible from the Android device. These resources are served in a Secure Context and can use WebXR capabilities.
Set up a supported device
AR experiences on Android can only be run on an ARCore supported device . Ensure that the device has Google Play Services for ARinstalled and enabled.
To verify that the device is correctly configured to run WebXR, browse to a sample WebXR page in a compatible browser .
Next steps
Now that you have set up your development environment to create AR experiences using WebXR, you can:
- Learn how to create an immersive AR session using WebXR .
- Try WebXR Samples .

