daovanhuy/nport

NPort is a powerful, lightweight ngrok alternative that creates secure HTTP/HTTPS tunnels from your localhost to public URLs using Cloudflare's global edge network. No configuration, no accounts, just instant tunnels with custom subdomains!

โ˜… 0Forks 0GitHub โ†—Compare

Project website โ†—

README

NPort

๐Ÿš€ Free & open source ngrok alternative - Tunnel localhost to the internet via Cloudflare Edge

GitHub NPM Website License

What is NPort?

nport

NPort is a powerful, lightweight ngrok alternative that creates secure HTTP/HTTPS tunnels from your localhost to public URLs using Cloudflare's global edge network. No configuration, no accounts, just instant tunnels with custom subdomains!

Perfect for:

  • ๐Ÿš€ Development environments - Share your local work instantly
  • ๐Ÿ”’ Testing webhooks - Receive webhooks from GitHub, Stripe, PayPal, etc.
  • ๐Ÿ“ฑ Mobile testing - Test your web app on real devices
  • ๐Ÿ› ๏ธ API development - Debug integrations with external services
  • ๐Ÿ‘ฅ Demo to clients - Show your progress without deployment

โœจ Features

  • โšก Instant Setup: One command to expose your localhost
  • ๐ŸŒ Custom Subdomains: Choose your own URL (e.g., myapp.nport.link)
  • ๐Ÿ”’ Automatic HTTPS: SSL/TLS encryption via Cloudflare
  • ๐ŸŒ Global Edge Network: Fast connections worldwide via Cloudflare
  • ๐Ÿ“ก WebSocket Support: Full WebSocket and Server-Sent Events support
  • ๐ŸŽฏ No Configuration: Works out of the box
  • ๐Ÿ’ป Cross-Platform: Windows, macOS, and Linux support
  • ๐Ÿ†“ 100% Free: No accounts, no limits, no paywalls
  • ๐Ÿ”“ Open Source: MIT licensed

๐Ÿ“ฆ Installation

NPM (Recommended)

# Global installation
npm install -g nport

# Or use npx without installation
npx nport 3000 -s myapp

From GitHub

npm install -g git+https://github.com/tuanngocptn/nport.git

๐Ÿš€ Quick Start

Basic Usage

Expose port 3000 with a random subdomain:

nport 3000

Output:

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
  NPort - Free & Open Source ngrok Alternative
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
  ๐ŸŒ Website: https://nport.link
  ๐Ÿ“ฆ NPM:     https://www.npmjs.com/package/nport
  ๐Ÿ’ป GitHub:  https://github.com/tuanngocptn/nport
  โ˜• Support: https://buymeacoffee.com/tuanngocptn
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿš€ Starting Tunnel for port 3000...
โœ” Tunnel created!
๐ŸŒ Public URL: https://user-1234.nport.link

Custom Subdomain

Choose your own subdomain:

nport 3000 -s myapp
# Creates: https://myapp.nport.link

Or using long form:

nport 3000 --subdomain myapp

๐Ÿ“– Usage Examples

Web Development

# Next.js
npm run dev
nport 3000 -s my-nextjs-app

# React (Create React App)
npm start
nport 3000 -s my-react-app

# Vue.js
npm run dev
nport 8080 -s my-vue-app

# Express.js
node server.js
nport 3000 -s my-api

Webhook Testing

# Start your local webhook receiver
node webhook-receiver.js

# Expose it to the internet
nport 4000 -s my-webhooks

# Use in GitHub webhook settings:
# https://my-webhooks.nport.link/webhook

Mobile Device Testing

# Start your local dev server
npm run dev

# Create tunnel
nport 3000 -s mobile-test

# Open on your phone:
# https://mobile-test.nport.link

๐ŸŽฏ CLI Options

nport <port> [options]
Option Short Description Example
<port> - Local port to tunnel (default: 8080) nport 3000
--subdomain -s Custom subdomain nport 3000 -s myapp
-s=value - Alternative format nport 3000 -s=myapp

๐Ÿ”ง How It Works

  1. You run nport 3000 -s myapp
  2. NPort creates a Cloudflare Tunnel
  3. DNS record is created: myapp.nport.link โ†’ Cloudflare Edge
  4. Cloudflared binary connects your localhost:3000 to Cloudflare
  5. Traffic flows through Cloudflare's global network to your machine
  6. On exit (Ctrl+C), tunnel and DNS are automatically cleaned up
Internet โ†’ Cloudflare Edge โ†’ Cloudflare Tunnel โ†’ Your localhost:3000
         (https://myapp.nport.link)

๐Ÿ›ก๏ธ Security

  • HTTPS by default: All tunnels use SSL/TLS encryption
  • Cloudflare protection: DDoS protection and security features
  • Automatic cleanup: Tunnels are removed when you stop the process
  • No data logging: We don't store or log your traffic

๐Ÿ†š Comparison with ngrok

Feature NPort ngrok
Price 100% Free Free tier limited
Custom subdomains โœ… Always โŒ Paid only
HTTPS โœ… Always โœ…
Account required โŒ No โœ… Yes
Time limits โŒ None โš ๏ธ Free tier limited
Open source โœ… MIT โŒ Proprietary
Global network โœ… Cloudflare โœ… ngrok Edge

๐Ÿงน Cleanup

NPort automatically cleans up resources when you:

  • Press Ctrl+C to exit
  • Kill the process
  • Terminal closes

The cleanup process:

  1. โœ… Deletes DNS record (myapp.nport.link)
  2. โœ… Removes Cloudflare Tunnel
  3. โœ… Stops cloudflared process

๐Ÿ› Troubleshooting

Binary not found

If you see "Cloudflared binary not found":

npm install -g nport --force

Port already in use

Make sure your local server is running on the specified port:

# Check if something is listening on port 3000
lsof -i :3000  # macOS/Linux
netstat -ano | findstr :3000  # Windows

Subdomain already taken

Choose a different subdomain name:

nport 3000 -s myapp-v2

Connection issues

The ERR Cannot determine default origin certificate path warning is harmless and can be ignored. It appears because cloudflared checks for certificate-based authentication (we use token-based instead).

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ’– Support

If you find NPort useful, please consider supporting the project:

๐Ÿ“„ License

MIT License - Feel free to use NPort in your projects!

๐Ÿ™ Credits

๐Ÿ”— Links


Made with โค๏ธ by Nick Pham

Contributors

tuanngocptn

Issues