May 19, 2020
Sometimes we want to test how our application looks and functions on a separate device. Using ngrok can help us expose a local server and access it online.
ngrok is a utility that can expose a web server running on your local machine to a configured URL that can be access online.
Exposing a local server via a publicly-accessible URL can be very useful for developers and QAs because you can demo your sites without requiring a deploy.
Using brew is the best way to install ngrok on your machine:
brew cask install ngrok
There are two alternative options:
npm install -g ngrok
You don't need to sign up to use ngrok but it does offer more privileges. More on this in the last section.
If your local project is already running on a specific port (such as
8000), you can just run:
ngrok http 8000
This will generate a publicly-accessible URL with HTTPS support. You can then use it to open the URL on a seperate device.
This is optional but doing so allows you to have longer session times and a maintainable list of running tunnels that you can see in the dashboard.
authtokenin the Setup & Installation section.
ngrok authtoken YOUR-TOKEN
This will add your authorization token to the ngrok.yml configuration file so that it is saved locally.
ngrok http 8000
You can now check that the generated URL is also listed in the Tunnels section: https://dashboard.ngrok.com/status/tunnels
That is all it takes to create a publicly-accessible URL that we can use to demo our site and test our features. I hope you find the tutorial useful. As always, thanks for dropping by.
Last updated: May 20, 2020