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:
- You need to expose a local development server to the internet
- External services need to call back to your local machine
- You want to share a local URL with others for testing
- You need to receive webhooks from third-party services
Installation
localtunnel requires Node.js. Install it globally:
npm install -g localtunnel
Or as a project dependency:
npm install localtunnel
CLI Usage
Basic usage (non-interactive)
lt --port 8000
With specific subdomain (request only, not guaranteed)
lt --port 8000 --subdomain my-app
Using environment variables
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:
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 exposesubdomain(string) - Request specific subdomainhost(string) - Proxy server URL (default: https://localtunnel.me)local_host(string) - Proxy to different hostnamelocal_https(boolean) - Enable HTTPS tunnelinglocal_cert,local_key,local_ca(string) - Certificate pathsallow_invalid_cert(boolean) - Disable cert checks
Non-interactive usage in OpenCode
Since OpenCode runs in non-interactive mode:
- Always use
npx localtunnelor the CLI - Do not use interactive prompts - Run in background - Use run_background_process for long-lived tunnels
- Handle tunnel URL - Extract and display the URL to the user
- Clean up - Close tunnel when done using
tunnel.close()or process termination
Example for running a tunnel in background:
// 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
closeevent - For production use, consider proper deployment instead of localtunnel
- Some features require the tunnel to stay running