<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashay Tiwari</title>
    <description>The latest articles on DEV Community by Ashay Tiwari (@ashay_tiwari_3658168ad5db).</description>
    <link>https://dev.to/ashay_tiwari_3658168ad5db</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3114225%2Fecf3ef8c-a7e9-4872-a8bf-039005be28df.jpg</url>
      <title>DEV Community: Ashay Tiwari</title>
      <link>https://dev.to/ashay_tiwari_3658168ad5db</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashay_tiwari_3658168ad5db"/>
    <language>en</language>
    <item>
      <title>Tunneling Made Simple: Exposing Local React and Node Apps with ngrok and LocalTunnel</title>
      <dc:creator>Ashay Tiwari</dc:creator>
      <pubDate>Thu, 01 May 2025 20:09:17 +0000</pubDate>
      <link>https://dev.to/ashay_tiwari_3658168ad5db/tunneling-made-simple-exposing-local-react-and-node-apps-with-ngrok-and-localtunnel-5g1g</link>
      <guid>https://dev.to/ashay_tiwari_3658168ad5db/tunneling-made-simple-exposing-local-react-and-node-apps-with-ngrok-and-localtunnel-5g1g</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;✨ Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Ever wanted to test your local web app on your phone? Share a work-in-progress with a client? Or receive webhooks from services like Stripe or GitHub?&lt;/p&gt;

&lt;p&gt;This blog post is your complete guide to securely exposing local development servers to the internet — whether it's a React.js frontend or a Node.js REST API backend.&lt;/p&gt;

&lt;p&gt;We’ll explore two popular tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔗 LocalTunnel – simple and open-source&lt;/li&gt;
&lt;li&gt;🚀 ngrok – powerful with an interactive dashboard and HTTPS support&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🔍 What You’ll Learn&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this guide, you’ll:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand the concept and use cases of local tunneling&lt;/li&gt;
&lt;li&gt;Set up a basic Node.js REST API and React.js app&lt;/li&gt;
&lt;li&gt;Expose both apps securely using LocalTunnel and ngrok&lt;/li&gt;
&lt;li&gt;Learn the pros/cons of each tool&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🛠️ Project Setup (React + Node)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;1️⃣ &lt;strong&gt;Node.js REST API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Steps to create a basic Express API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir backend-app
cd backend-app
npm init -y
npm install express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;server.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const app = express();
const PORT = 8000;

app.get('/api/greet', (req, res) =&amp;gt; {
  res.json({ message: 'Hello from Backend-App' });
});

app.listen(PORT, () =&amp;gt; {
  console.log(`API running at http://localhost:${PORT}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2️⃣ &lt;strong&gt;React.js Frontend App&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using Create React App:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app frontend-app
cd frontend
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, Using Vite (faster):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest frontend-app -- --template react
cd frontend
npm install
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;App.js&lt;/code&gt; as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

function App() {

  return &amp;lt;h1&amp;gt;Hello from Frontend-App&amp;lt;/h1&amp;gt;;
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;🌐 What is a Tunneling System?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When you're developing locally (e.g., &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; or &lt;a href="http://127.0.0.1:8000" rel="noopener noreferrer"&gt;http://127.0.0.1:8000&lt;/a&gt;), your apps are only accessible on your machine. If you want someone else — a client, teammate, or even a third-party API like Stripe — to access your local project, you need to expose it to the internet.&lt;/p&gt;

&lt;p&gt;That’s where tunneling tools come in.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A tunneling system creates a secure "bridge" between your local server and a public URL that anyone can access — even from outside your network.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Imagine it like building a secure pipe from your computer to the outside world. You don't have to deploy to a remote server or set up complex networking — just run a single command and you're live!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbgksd1yedo3g9uisyv0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbgksd1yedo3g9uisyv0.png" alt="Tunneling System Workflow" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🚀 Setting Up ngrok to Tunnel Your Local React and Node.js Apps&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s now walk through how to use ngrok to expose both your local backend and frontend to the internet.&lt;/p&gt;

&lt;p&gt;🔧 &lt;strong&gt;Step 1: Install ngrok&lt;/strong&gt;&lt;br&gt;
You can install ngrok globally via npm or download it from the official website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 1 – Install via npm:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g ngrok
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 2 – Download from website:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;https://ngrok.com/download&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Download and unzip the binary&lt;/li&gt;
&lt;li&gt;Move it to a directory in your system’s PATH&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🔐 Step 2: Sign up and authenticate ngrok (Optional but recommended)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're using a free ngrok account, you should sign up and connect your account to unlock features like custom subdomains and higher session limits.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up at &lt;a href="https://dashboard.ngrok.com" rel="noopener noreferrer"&gt;https://dashboard.ngrok.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Copy your authtoken from the dashboard&lt;/li&gt;
&lt;li&gt;Run the command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngrok config add-authtoken &amp;lt;your-token-here&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure your node and react servers are running locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌍 Step 3: Expose your servers with ngrok&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Note: ngrok Free Plan supports only one active tunnel at a time. If you want to expose both the React app and Node API simultaneously, you’ll need a Pro plan or use a different tunneling tool for one of them (e.g., LocalTunnel).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Tunnel the Node.js API (port 8000):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngrok http 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll get an output like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Forwarding     https://1e3f-106-219-85-57.ngrok-free.app -&amp;gt; http://localhost:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now access your API from this public URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tunnel the React frontend (port 3000):&lt;/strong&gt;&lt;br&gt;
If you want to expose the React app instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngrok http 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And again, ngrok will provide a public HTTPS URL like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Forwarding     https://6g4f-105-221-92-12.ngrok-free.app -&amp;gt; http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;🚀 Setting Up LocalTunnel for your React and Node.js Application&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;After covering &lt;code&gt;ngrok&lt;/code&gt;, let’s explore another tunneling tool: LocalTunnel — a free and open-source option that lets you share your local development environment via a public URL.&lt;/p&gt;

&lt;p&gt;Unlike ngrok, LocalTunnel does not require an account and allows multiple tunnels simultaneously (each on different ports and subdomains).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔧 Step 1: Install LocalTunnel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install it globally via npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g localtunnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure your node and react servers are running locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌍 Step 2: Expose your servers with LocalTunnel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can create tunnels for both apps using unique ports and optional subdomains.&lt;br&gt;
&lt;strong&gt;Tunnel the Node.js API:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lt --port 8000 --subdomain my-node-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a URL like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://my-node-api.loca.lt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tunnel the React frontend:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lt --port 3000 --subdomain my-react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a URL like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://my-react-app.loca.lt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;⚠️ Subdomains are first-come-first-served, and not guaranteed. If someone else is already using the same subdomain, you’ll get an error. If you omit --subdomain, a random one is generated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;🔁 Realtime Code Changes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LocalTunnel reflects real-time changes, just like ngrok, since it directly proxies your local server. You can continue editing your React or Node app, and the changes are reflected via the public tunnel.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🎉 That’s It!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You’ve now exposed your local apps to the world using ngrok or LocalTunnel. You can share those URLs with clients, test on your phone, or integrate with third-party services that need a public endpoint.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🆚 Comparison: ngrok vs. LocalTunnel&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;ngrok (Free Tier)&lt;/th&gt;
&lt;th&gt;LocalTunnel&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;🧰 Installation&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;npm install -g ngrok&lt;/code&gt; or native binary&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm install -g localtunnel&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔐 Account Required&lt;/td&gt;
&lt;td&gt;✅ Yes (for custom subdomains, dashboard access)&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔄 Supports Multiple Tunnels&lt;/td&gt;
&lt;td&gt;❌ No (only &lt;strong&gt;1 active tunnel&lt;/strong&gt; at a time)&lt;/td&gt;
&lt;td&gt;✅ Yes (multiple tunnels allowed)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🌐 Custom Subdomain&lt;/td&gt;
&lt;td&gt;✅ Yes (only with account)&lt;/td&gt;
&lt;td&gt;✅ Yes (but not always guaranteed)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔐 HTTPS Support&lt;/td&gt;
&lt;td&gt;✅ Yes (by default)&lt;/td&gt;
&lt;td&gt;✅ Yes (by default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🌍 URL Format&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://&amp;lt;random&amp;gt;.ngrok-free.app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://&amp;lt;random or subdomain&amp;gt;.loca.lt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🧑‍💻 Dashboard &amp;amp; Inspect Traffic&lt;/td&gt;
&lt;td&gt;✅ Yes (Web dashboard &amp;amp; HTTP request inspector)&lt;/td&gt;
&lt;td&gt;❌ No built-in dashboard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;💻 Real-time Code Updates&lt;/td&gt;
&lt;td&gt;✅ Yes (reflects local changes)&lt;/td&gt;
&lt;td&gt;✅ Yes (reflects local changes)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🕐 Session Duration&lt;/td&gt;
&lt;td&gt;~8 hours (free account), reconnect needed&lt;/td&gt;
&lt;td&gt;Until you manually close the tunnel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;📦 Open Source&lt;/td&gt;
&lt;td&gt;❌ Proprietary&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;💰 Pricing&lt;/td&gt;
&lt;td&gt;Free &amp;amp; paid tiers&lt;/td&gt;
&lt;td&gt;Fully free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🌐 Use Case Fit&lt;/td&gt;
&lt;td&gt;Best for &lt;strong&gt;professional demos&lt;/strong&gt;, webhooks, integrations&lt;/td&gt;
&lt;td&gt;Best for &lt;strong&gt;quick testing&lt;/strong&gt;, sharing with teammates&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🎯 Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this post, we explored how tunneling tools like ngrok and LocalTunnel help developers expose their local applications to the internet. ngrok offers advanced features like custom subdomains and request inspection, making it ideal for professional use, while LocalTunnel is a simpler, free alternative perfect for quick sharing and testing. Both tools provide a secure and real-time connection to your local environment, so you can choose the one that best fits your needs.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
