DEV Community

Nick - Ngoc Loc Coc
Nick - Ngoc Loc Coc

Posted on

Stop paying for ngrok! πŸ›‘ Meet NPort: The Free Open Source Alternative

The Problem 😫

We've all been there. You are demoing a Next.js app to a client, or testing a Stripe webhook locally. You fire up ngrok, send the link, and 2 hours later... the session expires.

Or worse, you restart your server, and the domain changes from random-xyz.ngrok-free.app to random-abc.ngrok-free.app. You have to go update your webhook settings again.

To get a stable, custom subdomain, you usually have to pay.

I got tired of this, so I decided to build my own solution using the massive edge network of Cloudflare.

Meet NPort.

Nport Home Page

What is NPort? πŸš€

NPort is a Node.js CLI tool that exposes your localhost to the internet.
It is 100% Free, Open Source, and designed to be a "set it and forget it" replacement for paid tunneling services.

Key Features:

  • πŸ’Έ 100% Free: No monthly fees.
  • πŸ”— Free Custom Subdomains: You can claim my-project.nport.link for free. No more random strings.
  • ⚑ Fast: Powered by Cloudflare Tunnel (Argo), so it uses their global edge network.
  • πŸ”’ Secure: Automatic HTTPS.
  • πŸ›  Self-Hostable: Don't trust my server? Fork the repo and deploy the backend to your own Cloudflare Workers account (Free tier) in 5 minutes.

πŸŽ₯ See it in action

I recorded a quick demo showing how fast it is to get a live HTTPS link:

How it compares

Feature NPort ngrok (Free Tier)
Price Free Free (Limited)
Custom Subdomain βœ… Included ❌ Paid feature
Session Time Unlimited ⚠️ Limited
Login Required ❌ No βœ… Yes
Open Source βœ… Yes (MIT) ❌ No

How to use it πŸ’»

You need Node.js installed.

1. Install via NPM

npm install -g nport

Enter fullscreen mode Exit fullscreen mode

2. Start your local server

Let's say your Next.js or Express app is running on port 3000.

3. Create a Tunnel

nport 3000 -s nickpham

Enter fullscreen mode Exit fullscreen mode

(The -s flag stands for subdomain)

Nport Terminal Startup

4. Done! πŸŽ‰

You can now access your app at https://nickpham.nport.link.

Here is what it looks like in the terminal:

As you can see, the connection is established instantly, and you get a beautiful, clean summary of your session.

Under the Hood βš™οΈ

For the curious technical folks, here is how NPort works:

  1. Client: The CLI (Node.js) creates a secure tunnel connection using the Cloudflare Tunnel protocol.
  2. Edge: The connection is routed through Cloudflare's nearest edge location.
  3. Backend: I used Cloudflare Workers (serverless) to handle the routing and subdomain logic. This ensures high availability and low latency.

Because it runs on Cloudflare Workers, the infrastructure cost is near zero, which is why I can offer this for free to the community.

Privacy & Self-Hosting πŸ›‘οΈ

Privacy is important. While NPort uses end-to-end encryption via Cloudflare, I understand that for sensitive projects, you might want full control.

NPort is fully open-source. You can fork the repository and deploy your own "Backend" on your own Cloudflare account.

  • You get your own private tunnel server.
  • You can use your own domain name (e.g., tunnel.your-company.com).
  • Check the server/README.md in the repo for instructions.

Give it a try!

I built this tool to help my own team, and I hope it helps you too.

If you find it useful, please consider giving it a Star ⭐ on GitHub. It helps more developers find the tool!

Happy Coding! πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Top comments (0)