@vkma.dev/tunnel — public HTTPS tunnels to a local server
On this page
@vkma.dev/tunnel gives a local dev server a public HTTPS address. You can open your build on a phone or hand the link to a colleague, and nothing gets deployed. The package has three entry points: a Vite plugin, the vkma-tunnel CLI and a Node API. It has two providers:
| Provider | Address | What it needs |
|---|---|---|
opentunnel (default) |
stable, https://<id>.opentunnel.xyz |
nothing: no account, the key stays on your machine |
cloudflared |
one-time *.trycloudflare.com, or stable on your own domain |
the cloudflared executable, plus a Cloudflare account for the stable one |
Quick start
The Vite plugin takes no options:
import { vkmaTunnel } from "@vkma.dev/tunnel/vite";
export default {
plugins: [vkmaTunnel()],
};npm install -D @vkma.dev/tunnel
npm run devpnpm add -D @vkma.dev/tunnel
pnpm devyarn add -D @vkma.dev/tunnel
yarn devbun add -D @vkma.dev/tunnel
bun run devThe plugin reads the dev server’s actual listening port, starts the tunnel and prints its URL next to Vite’s own lines:
➜ Local: http://localhost:5173/
➜ tunnel → https://4bznf5jcbkct.opentunnel.xyz (profile my-app · localhost:5173)The plugin works the same with vite preview. You can open a production build on a phone without deploying it.
Requests reach Vite without changes to your config. The package rewrites the Host header to an address Vite always accepts. HMR works through the tunnel. If the tunnel dies, the dev server keeps running and a red line appears in the terminal.
Options (all optional): enabled, config, provider, profile, qr, open, keepAlive, hostRewrite, and a provider’s section, opentunnel or cloudflared, with the keys it has in the config file. The plugin tunnels the server it is attached to.
Worth knowing
- The URL is public. Anyone who has the link reaches your dev server.
opentunneland the Cloudflare Quick Tunnel have no authentication. If a URL leaks, runvkma-tunnel reset. - Stopping Vite closes the tunnel. This happens on Ctrl+C, on
qand on SIGTERM. The service releases the route at once. Without it the next run would hit aroute_conflicterror. - Vite answers “Blocked request” to a foreign
Hostheader. By default the package rewrites the header for you. Turn the rewrite off only if your server needs the real publicHost. Then passhostRewrite: false(--no-host-rewritein the CLI) and add the address toserver.allowedHosts. A newopentunnelprofile gets its address only after the server has started. It then needs one more restart, and the plugin says so.
Next
- OpenTunnel — the default provider: a stable address and the profile.
- Cloudflare Tunnel — a one-time address without an account or a stable domain.
- CLI — the
vkma-tunnelcommands and flags. - Configuration — the
vkma-tunnel.config.*file and the priority of settings. - Node API —
createTunnelfor scripts and builds.