#
NPort
> ๐ Free & open source ngrok alternative - Tunnel localhost to the internet via Cloudflare Edge
[](https://github.com/tuanngocptn/nport)
[](https://www.npmjs.com/package/nport)
[](https://nport.link)
[](LICENSE)
[](https://www.typescriptlang.org/)
## What is NPort?
[](https://nport.link)
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
- ๐ฃ๏ธ **Multilingual**: English, Vietnamese and Spanish UI support
- ๐ **100% Free**: No accounts, no limits, no paywalls
- ๐ **Open Source**: MIT licensed
## ๐ฆ Installation
### Requirements
- **Node.js** >= 20.0.0
- **npm** >= 10.0.0
Check your versions:
```bash
node --version
npm --version
```
### NPM (Recommended)
```bash
# Global installation
npm install -g nport
# Or use npx without installation
npx nport 3000 -s myapp
```
### From GitHub
```bash
npm install -g git+https://github.com/tuanngocptn/nport.git
```
## ๐ Quick Start
### Basic Usage
Expose port 3000 with a random subdomain:
```bash
nport 3000
```
Output:
```
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ N P O R T โก๏ธ Free & Open Source from Vietnam โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โ Creating tunnel for port 3000...
๐ WE LIVE BABY!
๐ https://user-1234.nport.link ๐
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฑ๏ธ Time: 4h remaining
โ [1/2] Connection established...
โ [2/2] Compression enabled...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฅ KEEP THE VIBE ALIVE?
(Made with โค๏ธ in Vietnam)
โญ๏ธ Drop a Star: https://github.com/tuanngocptn/nport
โ๏ธ Buy Coffee: https://buymeacoffee.com/tuanngocptn
```
### Custom Subdomain
Choose your own subdomain:
```bash
nport 3000 -s myapp
# Creates: https://myapp.nport.link
```
Or using long form:
```bash
nport 3000 --subdomain myapp
```
## ๐ Usage Examples
### Web Development
```bash
# 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
```bash
# 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
```bash
# 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
```bash
nport [options]
```
| Option | Short | Description | Example |
|--------|-------|-------------|---------|
| `` | - | Local port to tunnel (default: 8080) | `nport 3000` |
| `--subdomain` | `-s` | Custom subdomain | `nport 3000 -s myapp` |
| `--backend` | `-b` | Custom backend URL (temporary) | `nport 3000 -b https://your-backend.com` |
| `--set-backend` | - | Save backend URL permanently | `nport --set-backend https://your-backend.com` |
| `--language` | `-l` | Set language (en/vi/es) or prompt | `nport 3000 -l es` |
| `--version` | `-v` | Show version information | `nport -v` |
### Language Options
NPort supports multiple languages with automatic detection on first run.
```bash
# Set language directly
nport 3000 --language en # English
nport 3000 -l vi # Vietnamese
nport 3000 -l es # Espaรฑol
# Open language selection menu
nport --language # Interactive prompt
nport -l # Interactive prompt
```
On first run or when using `--language` without a value, you'll see an interactive language picker. Your choice is automatically saved for future sessions.
### Backend URL Options
NPort uses a default backend at `https://api.nport.link`, but you can use your own backend server.
#### Temporary Backend (One-time Use)
Use a custom backend for just the current session:
```bash
# Use custom backend via CLI flag
nport 3000 --backend https://your-backend.com
nport 3000 -b https://your-backend.com
# Use custom backend via environment variable
export NPORT_BACKEND_URL=https://your-backend.com
nport 3000
# Combine with other options
nport 3000 -s myapp -b https://your-backend.com
```
#### Persistent Backend (Saved Configuration)
Save a backend URL to use automatically in all future sessions:
```bash
# Save backend URL permanently
nport --set-backend https://your-backend.com
# Now all future commands will use this backend
nport 3000 # Uses saved backend
nport 3000 -s myapp # Uses saved backend
# Clear saved backend (return to default)
nport --set-backend
# Override saved backend temporarily
nport 3000 -b https://different-backend.com
```
**Configuration Priority:**
1. CLI flag (`--backend` or `-b`) - Highest priority
2. Saved config (`--set-backend`)
3. Environment variable (`NPORT_BACKEND_URL`)
4. Default (`https://api.nport.link`) - Lowest priority
**Configuration Storage:**
Your backend preference is saved in `~/.nport/config.json`
This is useful if you want to:
- **Self-host**: Run your own NPort backend (see [server/](server/) directory)
- **Development**: Test against a local backend
- **Custom domains**: Use your own domain for tunnel URLs
- **Enterprise**: Use a company-hosted backend server
### Version Information
```bash
# Check current version and updates
nport -v
nport --version
```
## ๐ง 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)
```
## ๐๏ธ Project Structure
```
nport/
โโโ src/ # TypeScript source files
โ โโโ index.ts # Entry point
โ โโโ tunnel.ts # Tunnel orchestration
โ โโโ api.ts # Backend API client
โ โโโ args.ts # CLI argument parser
โ โโโ binary.ts # Cloudflared process manager
โ โโโ ui.ts # Console UI components
โ โโโ lang.ts # Multilingual support
โ โโโ types/ # TypeScript type definitions
โ โโโ ...
โ
โโโ tests/ # Unit tests (vitest)
โโโ dist/ # Compiled output
โโโ bin/ # cloudflared binary (downloaded)
โ
โโโ server/ # Backend (Cloudflare Worker)
โโโ website/ # Static landing page
โโโ docs/ # Documentation
โ โโโ ARCHITECTURE.md # Technical architecture
โ โโโ API.md # API reference
โ โโโ CONTRIBUTING.md # Contribution guide
โโโ .ai/ # AI context files
```
## ๐ก๏ธ 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
- **Privacy**: Anonymous analytics (can be disabled with `NPORT_ANALYTICS=false`)
## ๐ 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 (4h auto-cleanup) | โ ๏ธ Free tier limited |
| Open source | โ
MIT | โ Proprietary |
| Global network | โ
Cloudflare | โ
ngrok Edge |
| Multilingual | โ
EN/VI/ES | โ English only |
## ๐งน 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
Tunnels also auto-cleanup after **4 hours** to prevent resource waste.
## ๐ Troubleshooting
### Binary not found
If you see "Cloudflared binary not found":
```bash
npm install -g nport --force
```
### Port already in use
Make sure your local server is running on the specified port:
```bash
# 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:
```bash
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).
### Change language
To change your language preference:
```bash
nport --language
# or
nport -l
```
Then select your preferred language from the menu.
## ๐ Supported Languages
- ๐บ๐ธ **English** (`en`) - Default
- ๐ป๐ณ **Vietnamese** (`vi`) - Tiแบฟng Viแปt
- ๐ช๐ธ **Spanish** (`es`) - Espaรฑol
Want to add your language? Contributions are welcome! Check out the [Contributing Guide](docs/CONTRIBUTING.md).
## ๐ค 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
See [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) for detailed guidelines.
### Development Setup
```bash
# Clone the repository
git clone https://github.com/tuanngocptn/nport.git
cd nport
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run tests
npm test
# Run CLI locally
node dist/index.js 3000 -s test
```
## ๐ Support
If you find NPort useful, please consider supporting the project:
- โญ [Star on GitHub](https://github.com/tuanngocptn/nport)
- โ [Buy me a coffee](https://buymeacoffee.com/tuanngocptn)
- ๐ฌ Share with your friends and colleagues
- ๐ [Report bugs](https://github.com/tuanngocptn/nport/issues)
- ๐ [Add translations](docs/CONTRIBUTING.md#adding-translations)
## ๐ License
[MIT License](LICENSE) - Feel free to use NPort in your projects!
## ๐ Credits
- Created by [Nick Pham](https://github.com/tuanngocptn) from Vietnam
- Inspired by [ngrok](https://ngrok.com) and [localtunnel](https://github.com/localtunnel/localtunnel)
- Powered by [Cloudflare Tunnels](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/)
## ๐ Links
- ๐ Website: [https://nport.link](https://nport.link)
- ๐ฆ NPM: [https://www.npmjs.com/package/nport](https://www.npmjs.com/package/nport)
- ๐ป GitHub: [https://github.com/tuanngocptn/nport](https://github.com/tuanngocptn/nport)
- ๐ง Email: tuanngocptn@gmail.com
---
Made with โค๏ธ in Vietnam by [Nick Pham](https://github.com/tuanngocptn)