> Markdown version of https://tuna.am/en/docs/tunnels/migrate/localtunnel/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# 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](https://tuna.am/en/docs/guides/install/install-cli.md) and sign in:

```shell
tuna login

```

In CI and Docker, use an [API key](https://my.tuna.am/api_keys?lang=en) 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](https://tuna.am/en/docs/tunnels/http.md#free-subdomain): `--subdomain=<your-subdomain>`;
* a subdomain with any available name comes with a [subscription](https://tuna.am/#pricing): it's reserved for you and nobody else can take it.

Without `--subdomain`, the address is [dynamic](https://tuna.am/en/docs/tunnels/http.md#dynamic) and changes when you reconnect.

## Node.js API

Instead of the `localtunnel` package, use the [Node.js SDK](https://tuna.am/en/docs/guides/install/sdk/node.md): `npm install @tuna-am/sdk`. The SDK reads the API key from `TUNA_API_KEY`.

Before:

```js
const localtunnel = require('localtunnel');

const tunnel = await localtunnel({ port: 3000, subdomain: 'myapp' });
console.log(tunnel.url);
tunnel.on('close', () => console.log('closed'));

```

After:

```js
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](https://tuna.am/en/docs/tunnels/inspect.md) at `http://127.0.0.1:4040`: every request and response, with replay.
* Access control: a [password](https://tuna.am/en/docs/tunnels/http.md#basic-auth), a [key in a header](https://tuna.am/en/docs/tunnels/http.md#key-auth), [IP ranges](https://tuna.am/en/docs/tunnels/http.md#cidr).
* [Webhook signature verification](https://tuna.am/en/docs/tunnels/http.md#verify-webhook) for GitHub, GitLab, Sentry and Linear.
* [Serving a directory](https://tuna.am/en/docs/tunnels/http.md#file-server) without your own web server: `tuna http -f ./dist`.
* [TCP tunnels](https://tuna.am/en/docs/tunnels/tcp.md) for databases, SSH and other services, with a subscription.
