· NGSRV Team
How to share a Next.js 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.
App Router and Pages Router both work. ngsrv forwards HTTP; your hot reload stays local.
Steps
# 1. Start Next.js
npm run dev
# 2. In another terminal, tunnel the port
ngsrv http 3000
Check next.config.js if the dev server complains about the hostname.
If the dev server blocks the public host
Add the ngsrv hostname to experimental.allowedDevOrigins in next.config.js if the dev server blocks the public host.
Reserve a URL that does not change
ngsrv http 3000 --subdomain nextjs-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: nextjs
port: 3000
subdomain: nextjs-preview
Then ngsrv run.