How to Host Networked-Aframe on a Server
by Jennifer Wang (2022)
Once you've followed Networked-Aframe's getting started guide and have a local instance of NAF the next step is to deploy your code to a server so you can share your experience over the internet.
There are many ways to host your experience, ranging from super simple but without much customization, to quite complex with lots of customization. This post will describe the various methods from simplest to most complex.
Glitch.com (~5 minute setup time)
Cost: Free!
Custom domain: Not yet
Steps:
Sign up for a Glitch.com account (you can sign in with GitHub)
Open the Networked-Aframe Glitch Starter Pack
Click "Remix your own"
That's it! You can then click "Show" and you have a working example of NAF running at that URL. Open the URL in multiple tabs and you'll see the other avatars. If you're just in proof of concept phase I highly recommend you stop reading here and just use Glitch. It's also the defacto way the A-Frame community shares bugs and shows off examples, so its worth becoming familiar with it.
Heroku (~2 hours setup time)
Cost: Free tier
Custom domain: Yes
Steps:
Sign up for a Heroku account
Follow the hosting NodeJS on Heroku guide
Repeat the guide's steps but for your own local Networked-Aframe instance (created here)
Amazon Web Services (AWS) (~4 hours setup time)
Cost: Free tier for new customers
Custom domain: Yes
Steps:
Sign up for an AWS account
Follow the hosting NodeJS on AWS guide
Make sure ports TCP 80 and TCP 443 (only if you're using SSL, see below) are open in the security group
Push your local Networked-Aframe experience to a GitHub repo
Git clone your repo onto the AWS instance
Run npm install pm2 -g to install the pm2 process manager (this keeps your app alive even when you log off your server)
Start the app with PORT=80 pm2 start server/easyrtc-server.js