WebSocket Through a LocalToLink Tunnel
WebSocket support in v1.0
LocalToLink forwards WebSocket upgrade requests bidirectionally. Your local app handles the WebSocket protocol — the tunnel transports frames transparently.
npx localtolink --port 3000
Connect clients to:
wss://YOUR-SUBDOMAIN.localtolink.com/ws
The CLI also prints websocketUrl in --json output.
Common use cases
| Use case | Notes |
|----------|-------|
| Vite HMR | Configure hmr.protocol: "wss" — see Vite guide |
| Next.js Fast Refresh | Works with allowedDevOrigins — see Next.js guide |
| Chat / real-time apps | Connect to wss:// tunnel URL from browser or client |
| Twilio Media Streams | Twilio connects via WebSocket to your handler |
Client connection example
const ws = new WebSocket("wss://k7m2x9p4q1.localtolink.com/ws");
ws.onopen = () => ws.send("hello");
ws.onmessage = (event) => console.log(event.data);
Ensure your local server handles WebSocket upgrades on the same port LocalToLink forwards to.
Browser interstitial
WebSocket connections from browsers may require clicking through the interstitial first in a regular browser tab. Once bypassed via cookie, WebSocket connections on that subdomain proceed normally.
Programmatic WebSocket clients (not using the browser interstitial flow) connect directly.
Limits
- 20 concurrent visitor connections per tunnel
- 10 requests/second rate limit (HTTP; WebSocket frames use DATA channel)
- 2-hour session, 1 GB bandwidth
What is not supported
- TCP tunnels (non-HTTP/WebSocket) — deferred to v2.0
- WebSocket-specific debugging/inspector — use browser DevTools or server logs
Try it now
Start a tunnel from your project directory — no account required.
$ npx localtolink