There are two options for self-hosting a PlayCanvas game on your own domain.
- Embed a PlayCanvas hosted game using an iframe.
- Download your game from the Editor and upload the files to your own site.
When you publish to playcanvas.com, your game is assigned a URL. To embed your application in another page. You can simply include this URL as the
src property of an iframe.
<html> <head> <title>My Great Game</title> </head> <body> <iframe src="https://playcanv.as/p/PROJECT_ID/"></iframe> </body> </html>
Self-hosting on your own server
In order to host your game independently of PlayCanvas' servers, do the following:
- Go to your Project and open the Editor.
- Click on the button in the left hand side toolbar or click Publishing in the top left Menu
- This will open up the Publishing Dialog.
- Click the DOWNLOAD button
- Enter a name for your export. This will be the name of the .zip file that will be created for you.
- Select the Scenes you want to include in your export from the list. Notice that the Scene with the active banner icon will be the first scene loaded when your app is launched.
- Click on the 'WEB DOWNLOAD' button on the bottom to download a zip file of your project ready for deployment.
- Extract the contents of the zip file to a location of your choosing. The file
index.htmlwill load your game.
There are many options for running a web server. Here are a few:
- Easy: Install Python and run the command python -m SimpleHTTPServer from the same folder as your game's index.html. Then point your browser to http://localhost:8000
- Intermediate: Install XAMPP. Although this is a full PHP development environment, it includes an easy to configure Apache server.
- Advanced: Install Apache or nginx as a standalone service.