Often when I am creating a new website, I want to see how it is going to look on an actual device like my phone or tablet. You can use Chrome Web Tools for mimicking a device but it isn’t the same as an actual phone.
Chances are however that if you try and access the service using your IP Address on another device it will likely be blocked by your operating systems firewall. If you want to share the website or API with someone not on your network then you need to jump through lots of hoops such as forwarding the port on your router.
This is where ngrok comes in. It allows you to expose your local service or website over a secure tunnel.
Ngrok couldn’t be simpler to install.
./ngrok authtoken <auth token here>
Once Ngrok is installed it is simple to use.
./ngrok http 8000. You should see an output like this:
Ngrok gives you the http and https address that you can connect to and you will see the incoming HTTP requests on the console.
From their you can access the service running locally on your phone, tablet or even give it to someone else to try out.
You can also access a Dashboard locally on port
4040 if you want to get a detailed look of the requests and responses going to your service.
Ngrok is free for single use quick demos, if you need something more such as custom domains then you will need the paid account which starts at $5 per month.
Ngrok is one of those services that every developer should have in their toolbox. The dashboard is especially useful if you want to monitor the requests going to your service without another tool like fiddler. The free plan is good enough for most use cases, if you need more than the paid options are reasonabl