Home > database >  Is there a way to connect NextJS app on my phone trough local network in development like Create Rea
Is there a way to connect NextJS app on my phone trough local network in development like Create Rea

Time:12-04

enter image description here

It does not provide a local network URL like CRA.

CodePudding user response:

The server is accessible on the local network, as long as the network is configured properly (and doesn't have something like client isolation enabled). All you need to do is find out which IP address your network's router is allocating to you. On Windows, this can be done by checking the results of ipconfig. On Linux, you can use ip addr. Then, when you want to access the app from another device, just use the IP found above followed by the port set in next.js.

For example, I have a machine whose network IP address is 192.168.1.2. On that machine, I have a Next app running on port 56381.

ready - started server on 0.0.0.0:56381, url: http://localhost:56381

I can access it on my phone by going to 192.168.1.2:56381.

  • Related