DEV Community

Cover image for Deploying to your local IP address with Nextjs.

Deploying to your local IP address with Nextjs.

oluwadareseyi profile image Oluwadare Seyi ・1 min read

There's no doubting Nextjs as a powerful framework for building production-grade, hybrid web applications.

Sometimes, when building responsive applications, it is very important to be able to test on mobile and other devices in real-time. create-react-app does this out of the box, with next, we need to follow a few steps.

(It is important to note that for this to work, all the devices you want to test on have to be connected to the same network.)

  • Open your terminal and run the command ipconfig for windows or ifconfig for MacBooks. You'll see the network you're currently connected to, the IPv4 address being the current local IP address.

Now to the deployment.

On your terminal, run yarn dev -H [your IP address] or npm run dev -H [your IP address]. For example, yarn dev -H This creates a server with your application hosted on your local IP address, and the link shows up on your terminal using the default port of 3000, or any port you configured your app to run on.

That link can then be used on any device, and any changes you make to your app will be updated in real-time.

Happy Building!

Discussion (3)

Editor guide
firzatullahd profile image
Firzatullah Dwiko Ramadhan

very helpful! thanks a lot

sereybuth120 profile image
APEX • Edited

thx. but how do I switch back to local hosting?

oluwadareseyi profile image
Oluwadare Seyi Author

Hi. Just run yarn dev on another terminal window or cancel the current deploy and run the dev command.