How to Debug a Next.js App Running Locally on iPhone
Debugging a Next.js running locally on your iPhone is easy.
You need to first get the IP address of the machine running Next.js locally. This can be done by running one of the following commands from the machine running Next.js.
If you're on a wired Ethernet connection:
ipconfig getifaddr en1
If you're on a wireless connection:
ipconfig getifaddr en0
I can never remember the commands, so I set up an alias.
alias getip="ipconfig getifaddr en0"
If you're on Mac, and assuming Next.js is running on the default port 3000
,
you can run the following command to copy the URL to your clipboard.
echo "http://$(eval 'ipconfig getifaddr en0'):3000" | pbcopy
Or if you're using the alias:
echo "http://$(eval 'getip'):3000" | pbcopy
Then, I'll send myself the URL with iMessage to open the locally running app on my iPhone.
That's it, you're ready to debug!