If you are making a mobile game with Phaser then you'll have to develop on a desktop computer: Mac or Windows.
You'll also have to use a development server to see your work-in-progress at an address like http://localhost:8080.
But you can only access localhost
from the computer running the server.
Having to build and install your game every time before testing on a mobile device is a huge pain in the neck.
The good news is that you should be able to reach your local development server from a mobile device already!
In this article, we will show you how to do that on Mac and Windows as well as provide some troublshooting suggestions.
Everyone on the Same Network
First, make sure your phone is connected to the same network as your development computer.
This means the same WiFi network.
If your phone is connected to cellular 4G or 5G then it is not on the same WiFi network as your computer.
Everything else will not work if this first criterion is not met. So make sure your phone and your computer are connected to the same WiFi. 💯
Get Your Local IP Address
Next, you need the local or internal IP address of your development computer.
Every device that connects to your WiFi is given an internal IP address by the router.
This is different than the more common external or Internet-facing IP address that you find with sites like whatismyip.com.
Mac Users
Open Network Preferences by clicking on the WiFi icon in the top bar. It is near the battery meter, time, and Siri icons in the top right of the screen.
Select “Open Network Preferences…” at the bottom of the menu after all the available WiFi networks.
The System Preferences window will open and you should see a message right under “Status: Connected” that says:
Wi-Fi is connected to [NETWORK NAME] and has the IP address 10.0.0.*.
Depending on your setup the IP address might be more like: 192.168.*.*
where *
is a number.
Either way, those 4 numbers separated by 3 dots is your local IP address.
Windows Users
Launch a Command Prompt from the Start menu and run:
ipconfig
You'll get a readout with all kinds of information but you only care about the “IPv4 Address”.
It will be something like 10.0.0.*
or 192.168.*.*
depending on your setup.
Either way, those 4 number separated by 3 dots is your local IP address.
Open From Your Phone
First, make sure your local development server is running and that you can access the game from http://localhost:8080 (or similar) as you normally do.
The 4 numbers to the right of the :
is the port number. You will need to combine your local IP with this port number.
Open the web browser on your phone and type in the local IP address on your development computer followed by :
and the port number.
It will be something like this:
|
|
And that's it! You should see the game on your phone. 🎉
Troubleshooting
If you are unable to load your game then you are likely using Windows. 😅
Check any firewall or anti-virus applications or services that may be running and blocking ports.
You can also try running your server on a different port like 8000
, 9000
, 10000
, or anything up to around 65000
.
Another potential solution is to try a different web server for serving up your game or update the underlying package or framework. This is unlikely to be the problem but you never know!
An even less likely scenario is that your router employs a strict configuration for local network traffic. You'll have to consult your router for this.
Next Steps
You can now test games on your phone without building it for Android or iOS first.
To make the test even better you can choose to save the webpage as an application. This saves an icon that you can launch as if it was a native app.
Let us know in the comments below if anything doesn’t work or is unclear. We’ll be happy to fix or clarify!
Be sure to sign up for our newsletter so you don't miss any future Phaser 3 game development tips and techniques!
Drop your email into the box below.
Don't miss any Phaser 3 game development content
Subscribers get exclusive tips & techniques not found on the blog!
Join our newsletter. It's free. We don't spam. Spamming is for jerks.