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
localhost
or*.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 forwarding in 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
localhost
on 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 AR installed 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.