skies.dev

How to Debug a Next.js App Running Locally on iPhone

1 min read

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.

~/.zshrc
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!

Hey, you! 🫵

Did you know I created a YouTube channel? I'll be putting out a lot of new content on web development and software engineering so make sure to subscribe.

(clap if you liked the article)

You might also like