Deployment
After you have completed and tested your WebGL build locally, the next step is to deploy it so that others can access it over the network. Deployment involves uploading the build files to a web server or hosting platform where participants can open the build in their browser. This section covers how to host your build on a server.
Host Locally
When you create a WebGL build using Unity's Build and Run, Unity automatically starts a temporary local web server, hosts the build, and opens it in your default browser. This is convenient for quick testing, but once the server stops, you can't simply reopen the build. To run it again, either rebuild with Build and Run or start your own local server.
Use one of the following methods to host your WebGL build locally:
- Python
- Node.js
- PHP
- Simple Web Server
Run the following command:
python -m http.server 8000
Open a web browser and navigate to http://localhost:8000.
Run the following command:
npx http-server -p 8000
(Without -p 8000, http-server uses port 8080 by default.)
Open a web browser and navigate to http://localhost:8000.
Run the following command:
php -S localhost:8000
Open a web browser and navigate to http://localhost:8000.
Find SimpleWebServer.exe in your Unity installation:
C:\Program Files\Unity\Hub\Editor\[Unity_Version]\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\SimpleWebServer.exe
Run it with your build's index.html file and a port number as arguments:
SimpleWebServer.exe "path/to/your/build/index.html" 8000
Open a web browser and navigate to http://localhost:8000.
Deploy WebGL Build to Server
Once your WebGL build is ready, you can deploy it to a web server so that participants can access it remotely. To do this, upload the entire contents of your WebGL build folder (including index.html, the Build/ folder, TemplateData/, and StreamingAssets/, which holds the simulator's Addressables content) to your server.
After uploading, verify that index.html is reachable and loads correctly in a browser, and that your configured server is accessible from the network.
Once deployed, participants can open the build in their browser using the server URL. For builds that require dynamic configuration (such as passing a worker ID), you can append query strings to the URL. This is covered in the next section.
Accessing the Build with Query Strings
If your build is configured to fetch worker IDs from the URL for authorization, the URL to the index.html file must include the search query parameter, added either manually or automatically by a third-party service.
Localhost example:
http://localhost:8000/index.html?search=MTURK12345
Server example:
https://yourserver.com/YourBuild/index.html?search=MTURK12345
The WebGL build reads the search query parameter to identify the participant or configure the session dynamically. If your build does not use this feature, appending query strings is not necessary.
For more details on configuring the server and authorization, see the Server Authorization Guide.