Steps to use ngrok for reactjs

Ajay Singh
3 min readMar 3, 2023

--

Ngrok is a tool that allows you to create a secure tunnel to your local development environment and expose it to the internet. This can be useful when developing a ReactJS application, as it allows you to easily share your work with others or test it on different devices.

Here are the steps to use ngrok for ReactJS:

1. Install ngrok:

To install ngrok, follow these steps:

  • Go to the ngrok website: https://ngrok.com/
  • Sign up for a free account if you don’t already have one.
  • Once you are logged in, download the ngrok binary for your operating system. You can find the download links on the ngrok dashboard under the “Download” section.
  • Extract the ngrok binary from the downloaded archive.
  • Move the ngrok binary to a directory in your PATH. For example, you can move it to /usr/local/bin on macOS or Linux.
  • Open a terminal and run the command ngrok version to verify that ngrok is installed correctly.

That’s it! You have now installed ngrok on your system and you can use it to create secure tunnels to your local development environment.

2. Start your ReactJS development server:

To start your ReactJS development server, follow these steps:

  1. Open a terminal window.
  2. Navigate to your ReactJS project directory using the cd command. For example, if your project is located in the Documents folder, you can navigate to it using the command cd Documents/my-react-app.
  3. Once you are in your project directory, run the command npm start to start the development server.
  4. Wait for a few seconds until the server is started. You should see a message in the terminal that says “Compiled successfully!”
  5. Your ReactJS application is now running on a local development server. You can access it by opening a web browser and navigating to http://localhost:3000 (or another port if you specified a different one).

That’s it! You have now started your ReactJS development server and you can begin developing your application.

3. Start ngrok:

To start ngrok, follow these steps:

  1. Open a terminal window.
  2. Navigate to the directory where you downloaded the ngrok binary. For example, if you downloaded it to your Downloads folder, you can navigate to it using the command cd Downloads.
  3. Extract the ngrok binary from the downloaded archive using the command unzip ngrok.zip.
  4. To start ngrok, run the command ./ngrok http 3000 (replace "3000" with the port number used by your ReactJS development server if it's different).
  5. Wait for a few seconds until ngrok has started. You should see a message in the terminal that says “Session Status: online”.
  6. Ngrok will provide a publicly accessible URL that you can use to access your local development environment. Copy this URL and share it with anyone you want to test your ReactJS application.

That’s it! You have now started ngrok and can use it to create a secure tunnel to your local development environment.

4. Get the ngrok URL:

To get the ngrok URL, follow these steps:

  1. Once ngrok has started, you should see a message in the terminal that says “Forwarding”. This message will also include the ngrok URL.
  2. The ngrok URL will look something like “https://xxxxxx.ngrok.io" (the “xxxxxx” part will be a unique identifier for your tunnel).
  3. Copy this URL and share it with anyone you want to test your ReactJS application.

That’s it! You have now obtained the ngrok URL and can use it to test your ReactJS application on different devices or share it with others for feedback.

That’s it! You can now use ngrok to test your ReactJS application on different devices or share it with others for feedback.

--

--

Ajay Singh

I love web development and I believe learning can’t stop in life and I am a very good listener, want greatness in life, passionate towards learning new things.