running a Development server on NextJS (on the network)

Viewed 10653

While using ReactJS, when we use the command npm start, It starts the development server on localhost:3000 and also on the network, 192.168.1.2:3000 This was super easy, I could test my app on all the devices by going into that address.

Recently I started learning NextJS and when I run the command npm run dev, I only see that it starts the development server on the local machine, not on the network. Is there a way to make it work just like it did with pure reactjs?

posting the screenshot, this is what it looks like with nextjs

3 Answers

It also listens on your local IP, just find out your local ip and do "192.168.1.x:3000" -- this would be your IP , you will see the server running on that port.

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

As @Deepinder Singh mentioned, Next.js dev server already listens on your local network.

To get your local network IP address run the following command. (tested only on mac)

ipconfig getifaddr en0

I can see you may be confused by the addres "0.0.0.0" you're seeing. But kindly go to your terminal and check your local ip address using the following command

ipconfig

then check the IPV4 address you see and use it instead of "0.0.0.0" and you're good to go.. for instance "192.168.43.131:3000"

Related