Authentication & Tokens
MekongTunnel works in two modes. You pick the one that fits your workflow — no account is required for basic use.
Two modes at a glance
| Free / Anonymous | With API Token | |
|---|---|---|
| Account needed | No | Yes (free account) |
| Subdomain | Random every time | Random, or your reserved subdomain with --subdomain |
| Example URL | happy-tiger-a1b2c3d4.proxy.mekongtunnel.dev | myapp.proxy.mekongtunnel.dev (with --subdomain myapp) |
| Shows in dashboard | No | Yes (v1.6.16+), even with a random URL |
| Tunnel lifetime | 24 h default, max 7 days | Same limits (7-day default with --subdomain) |
| npm / Python SDK | ✔ | ✔ |
| VS Code extension | ✔ | ✔ |
Both modes are free. An API token links your tunnels to your account and lets you use a reserved subdomain (Student plan and up) with
--subdomain.
Getting an API token
- Sign in at mekongtunnel.dev (opens in a new tab)
- Go to Dashboard → API Tokens
- Click New token, give it a name, copy the value
Keep the token safe — it is shown only once.
Option 1 — mekong login (recommended)
The easiest way. Opens your browser, you approve once, and the token is saved automatically to ~/.mekong/config.json.
mekong login Open this URL to log in:
https://mekongtunnel.dev/cli-auth?session=xxxx
Waiting for authorization.....
✔ Logged in as you@example.com
Saved login is now the default auth for this machine.
Run: mekong 3000 for a random URL, or mekong 3000 --subdomain myapp for a reserved one
See: mekong subdomains for your reserved names.From that point on, every mekong 3000 is linked to your account and shows in your dashboard, but still gets a random URL. Add --subdomain myapp to use a reserved subdomain.
mekong whoami # show logged-in account
mekong logout # remove saved credentialsOption 2 — --token flag
Pass your token directly on the command line:
mekong --token mkt_xxxxxxxxxxxx 3000Option 3 — MEKONG_TOKEN environment variable
Set the token once in your shell profile and never think about it again:
export MEKONG_TOKEN=mkt_xxxxxxxxxxxx
mekong 3000Great for CI/CD pipelines and Docker containers.
Token resolution order
The CLI checks for a token in this order, using the first one it finds:
--tokenflagMEKONG_TOKENenvironment variable~/.mekong/config.json(written bymekong login)- (none — runs anonymously)
Either way the tunnel gets a random subdomain unless you pass --subdomain.
Reserved subdomains
A reserved subdomain is tied to your account and stays the same every time you connect.
To create one:
- Go to Dashboard → Subdomains
- Click Reserve subdomain
- Pick a name — e.g.
myapp - Your tunnel URL becomes
https://myapp.proxy.mekongtunnel.dev
To use it, pass the name explicitly: mekong 3000 --subdomain myapp (or -sd myapp). This requires mekong login or a token. Without --subdomain, a logged-in tunnel keeps its random name — the token only links it to your account.
Raw SSH with a token
If you use ssh directly instead of the mekong CLI, pass the token as an environment variable via SetEnv:
ssh -o SetEnv="MEKONG_API_TOKEN=mkt_xxxxxxxxxxxx" \
-t -R 80:localhost:3000 proxy.mekongtunnel.devThis links the tunnel to your account. Add MEKONG_SUBDOMAIN=myapp to use a reserved subdomain, and MEKONG_EXPIRE=48h if you want a specific tunnel lifetime.
npm / Node.js SDK
const mekong = require('mekong-cli/sdk') // or: require('mekong-cli')
// Uses saved login token automatically
const { url, stop } = await mekong.expose(3000)
console.log('Public:', url)
// Or pass a token explicitly
const { url } = await mekong.expose(3000, { token: 'mkt_xxx' })
// Auth helpers
await mekong.login() // browser flow — saves ~/.mekong/config.json
mekong.logout() // remove saved token
const info = mekong.whoami()
const tok = mekong.getToken() // reads from env / saved configPython SDK
import mekong_tunnel as mekong
# Uses saved login token automatically
tunnel = mekong.expose(8000)
print(tunnel.url) # https://happy-tiger-a1b2c3d4.proxy.mekongtunnel.dev
tunnel.stop()
# Or pass a token explicitly
tunnel = mekong.expose(8000, token='mkt_xxx')
# Context manager
with mekong.expose(8000) as t:
print(t.url) # tunnel is live inside the block
# Auth helpers
mekong.login() # browser flow — saves ~/.mekong/config.json
mekong.logout() # remove saved token
info = mekong.whoami()
tok = mekong.get_token()VS Code extension
The extension automatically reads your token in this order:
mekong.apiTokenVS Code settingMEKONG_TOKENenvironment variable~/.mekong/config.json(written bymekong login)
The simplest setup: run mekong login in your terminal once, then click Start Tunnel in VS Code — it picks up your login automatically.
To set the token in settings instead: open VS Code Settings (Ctrl+,), search for mekong, and paste your token into Mekong Tunnel → API Token.
Revoking a token
Go to Dashboard → API Tokens, find the token, and click Revoke. The token stops working immediately.