· NGSRV Team

How to share a Vite dev server online

You finished a feature branch and someone off your machine needs to click through it. Deploying a staging build works, but it is slow. Running npm run dev and tunneling it is faster.

Works with React, Vue, Svelte, and Solid templates that ship with Vite.

Steps

# 1. Start Vite
npm run dev

# 2. In another terminal, tunnel the port
ngsrv http 5173

Check vite.config.ts if the dev server complains about the hostname.

If the dev server blocks the public host

Set server.allowedHosts in vite.config.ts to include the ngsrv hostname, or use server.allowedHosts: true for short preview sessions.

Reserve a URL that does not change

ngsrv http 5173 --subdomain vite-preview

Hand that link to QA or a client. Same URL after you restart the tunnel.

Declarative config for teams

Check a ngsrv.yml into the repo so everyone runs the same tunnel names:

tunnels:
  - name: vite
    port: 5173
    subdomain: vite-preview

Then ngsrv run.