Migrating from localtunnel
localtunnel gives you a public HTTP address with a single npm command. In tuna it's also one command, and for Node.js code there's an SDK with a similar API.
Installing and signing inโ
Install tuna by following the instructions and sign in:
tuna login
In CI and Docker, use an API key in the TUNA_API_KEY variable.
Commandsโ
| localtunnel | tuna |
|---|---|
npx localtunnel --port 3000 | tuna http 3000 |
lt --port 3000 --subdomain myapp | tuna http 3000 --subdomain=myapp |
lt --port 3000 --local-host 192.168.1.10 | tuna http 192.168.1.10:3000 |
localtunnel gives you a subdomain only if it happens to be free. In tuna the address belongs to you:
- every account has a free permanent subdomain:
--subdomain=<your-subdomain>; - a subdomain with any available name comes with a subscription: it's reserved for you and nobody else can take it.
Without --subdomain, the address is dynamic and changes when you reconnect.
Node.js APIโ
Instead of the localtunnel package, use the Node.js SDK: npm install @tuna-am/sdk. The SDK reads the API key from TUNA_API_KEY.
Before:
const localtunnel = require('localtunnel');
const tunnel = await localtunnel({ port: 3000, subdomain: 'myapp' });
console.log(tunnel.url);
tunnel.on('close', () => console.log('closed'));
After:
const tuna = require('@tuna-am/sdk');
const controller = new AbortController();
await tuna.forward({
protocol: 'http',
subdomain: 'myapp',
signal: controller.signal,
onEvent: (e) => {
if (e.type === 'connected') console.log(e.url);
},
}, '127.0.0.1:3000');
controller.abort() closes the tunnel. If the connection drops, the SDK reconnects and keeps the address.
What else tuna hasโ
- A Request Inspector at
http://127.0.0.1:4040: every request and response, with replay. - Access control: a password, a key in a header, IP ranges.
- Webhook signature verification for GitHub, GitLab, Sentry and Linear.
- Serving a directory without your own web server:
tuna http -f ./dist. - TCP tunnels for databases, SSH and other services, with a subscription.