--- name: localtunnel description: Expose localhost to the world for easy testing and sharing using localtunnel license: MIT compatibility: opencode metadata: audience: agents use-case: development --- ## What I do localtunnel exposes your localhost to the world for easy testing and sharing. It creates a public URL that forwards requests to your local development server. This is useful for: - Testing webhooks from external services (Twilio, Stripe, etc.) - Sharing work-in-progress with others - Browser testing from external tools ## When to use me Use this skill when: 1. You need to expose a local development server to the internet 2. External services need to call back to your local machine 3. You want to share a local URL with others for testing 4. You need to receive webhooks from third-party services ## Installation localtunnel requires Node.js. Install it globally: ```bash npm install -g localtunnel ``` Or as a project dependency: ```bash npm install localtunnel ``` ## CLI Usage ### Basic usage (non-interactive) ```bash lt --port 8000 ``` ### With specific subdomain (request only, not guaranteed) ```bash lt --port 8000 --subdomain my-app ``` ### Using environment variables ```bash PORT=3000 lt ``` ### Common CLI options - `--port` - Local port number to expose (required) - `--subdomain` - Request a specific subdomain (not guaranteed) - `--local-host` - Proxy to a hostname other than localhost ## API Usage For programmatic use in Node.js scripts: ```javascript const localtunnel = require('localtunnel'); (async () => { const tunnel = await localtunnel({ port: 3000 }); console.log('Tunnel URL:', tunnel.url); tunnel.on('close', () => { console.log('Tunnel closed'); }); })(); ``` ### API options - `port` (number, required) - Local port to expose - `subdomain` (string) - Request specific subdomain - `host` (string) - Proxy server URL (default: https://localtunnel.me) - `local_host` (string) - Proxy to different hostname - `local_https` (boolean) - Enable HTTPS tunneling - `local_cert`, `local_key`, `local_ca` (string) - Certificate paths - `allow_invalid_cert` (boolean) - Disable cert checks ## Non-interactive usage in OpenCode Since OpenCode runs in non-interactive mode: 1. **Always use `npx localtunnel` or the CLI** - Do not use interactive prompts 2. **Run in background** - Use run_background_process for long-lived tunnels 3. **Handle tunnel URL** - Extract and display the URL to the user 4. **Clean up** - Close tunnel when done using `tunnel.close()` or process termination Example for running a tunnel in background: ```javascript // Start local server first, then: const tunnel = await localtunnel({ port: 3000 }); console.log('Public URL:', tunnel.url); ``` ## Important notes - The tunnel URL is assigned dynamically and may change on reconnect - Tunnels can close unexpectedly; handle the `close` event - For production use, consider proper deployment instead of localtunnel - Some features require the tunnel to stay running