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
ipconfigfor windows or
ifconfigfor 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 18.104.22.168. 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.