@chromaui/localtunnel

中文文档
2.0.4发布于 2021/09/17MITCommonJS近 30 天下载 14万

Expose localhost to the world

原始使用文档
文档目录9 节
  1. Installation
  2. CLI usage
  3. Arguments
  4. API
  5. localtunnel(port [,options][,callback])
  6. Tunnel
  7. other clients
  8. server
  9. License

@chromaui/localtunnel

localtunnel exposes your localhost to the world for easy testing and sharing! No need to mess with DNS or deploy just to have others test out your changes.

Great for working with browser testing tools like browserling or external api callback services like twilio which require a public url for callbacks.

Installation

yarn add @chromaui/localtunnel

CLI usage

Assuming your local server is running on port 8000, just use the lt command to start the tunnel.

lt --port 8000

Thats it! It will connect to the tunnel server, setup the tunnel, and tell you what url to use for your testing. This url will remain active for the duration of your session; so feel free to share it with others for happy fun time!

You can restart your local server all you want, lt is smart enough to detect this and reconnect once it is back.

Arguments

Below are some common arguments. See lt --help for additional arguments

  • --subdomain request a named subdomain on the localtunnel server (default is random characters)
  • --local-host proxy to a hostname other than localhost

You may also specify arguments via env variables. E.x.

PORT=3000 lt

API

The localtunnel client is also usable through an API (for test integration, automation, etc)

localtunnel(port [,options][,callback])

Creates a new localtunnel to the specified local port. Will return a Promise that resolves once you have been assigned a public localtunnel url. options can be used to request a specific subdomain. A callback function can be passed, in which case it won't return a Promise. This exists for backwards compatibility with the old Node-style callback API. You may also pass a single options object with port as a property.

const localtunnel = require('@chromaui/localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });

  // the assigned public url for your tunnel
  // i.e. https://abcdefgjhij.localtunnel.me
  tunnel.url;

  tunnel.on('close', () => {
    // tunnels are closed
  });
})();

options

  • port (number) [required] The local port number to expose through localtunnel.
  • subdomain (string) Request a specific subdomain on the proxy server. Note You may not actually receive this name depending on availability.
  • host (string) URL for the upstream proxy server. Defaults to https://localtunnel.me.
  • local_host (string) Proxy to this hostname instead of localhost. This will also cause the Host header to be re-written to this value in proxied requests.
  • local_https (boolean) Enable tunneling to local HTTPS server.
  • local_cert (string) Path to certificate PEM file for local HTTPS server.
  • local_key (string) Path to certificate key file for local HTTPS server.
  • local_ca (string) Path to certificate authority file for self-signed certificates.
  • allow_invalid_cert (boolean) Disable certificate checks for your local HTTPS server (ignore cert/key/ca options).

Refer to tls.createSecureContext for details on the certificate options.

Tunnel

The tunnel instance returned to your callback emits the following events

eventargsdescription
requestinfofires when a request is processed by the tunnel, contains method and path fields
errorerrfires when an error happens on the tunnel
closefires when the tunnel has closed

The tunnel instance has the following methods

methodargsdescription
closeclose the tunnel

other clients

Clients in other languages

go gotunnelme

go go-localtunnel

C#/.NET localtunnel-client

server

See localtunnel/server for details on the server that powers localtunnel.

License

MIT

版本与发布记录

@chromaui/localtunnel 共发布 10 个版本,首次发布于 2018/10/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.4latest2021/09/175 年前
2.0.32021/02/175 年前
2.0.22021/01/225 年前
2.0.12019/08/257 年前
2.0.02019/07/167 年前
1.10.12019/07/167 年前

关于 @chromaui/localtunnel 的常见问题

@chromaui/localtunnel 是什么?

Expose localhost to the world

如何安装 @chromaui/localtunnel?

在项目目录运行 npm install @chromaui/localtunnel,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 lt,可以用 npx lt 直接运行。

@chromaui/localtunnel 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/chromaui__localtunnel 是否存在。

@chromaui/localtunnel 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@chromaui/localtunnel 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=8.3.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chromaui/localtunnel 可以商用吗?

@chromaui/localtunnel 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chromaui/localtunnel 的下载量有多少?

根据 npm 官方下载统计,@chromaui/localtunnel 在 2026/10/10 – 2026/11/08 这 30 天内被下载 139,519 次,日均约 4,651 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chromaui/localtunnel 还在维护吗?

最新版本 2.0.4 发布于 2021/09/17(5 年前);至今共发布 10 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。