Dev loop
gsx dev watches the project, keeps the Go server current, and reloads the browser. It is a Go binary and does the watching, generation, and rebuilding itself.
Run it
gsx devOpen the URL printed in the terminal and leave the command running while you edit the project.
The starter exposes the same thing as npm run dev, a script that runs go tool gsx dev; the wrapper exists only so one command also starts Vite. With no front-end pipeline, gsx dev --no-web keeps Node out of the loop entirely.
HTTPS on a local hostname
Camera and microphone APIs require a secure browser context on a LAN hostname. Use Vite's native TLS listener for the front door and set its public origin in the project .env:
VITE_DEV_URL=https://my-host:5173Configure server.host for that hostname and server.https with the certificate and key in vite.config.ts, keeping the rest of the existing configuration:
import { readFileSync } from "node:fs";
// Inside the existing Vite config's server options:
https: command === "serve" ? {
cert: readFileSync(".certs/dev.pem"),
key: readFileSync(".certs/dev-key.pem"),
} : undefined,For example, mkcert can issue the certificate for my-host after its local CA is installed. Keep the certificate files and .env out of version control. Every browser machine connecting to the hostname must trust the issuing CA.
gsx dev preserves the HTTPS scheme when resolving the host and port and passes the same VITE_DEV_URL to Vite and Go. Its control requests verify certificate chains and hostnames normally; they never bypass TLS verification. The Go backend can continue listening over HTTP on loopback. Vite also serves its reload WebSocket over the secure front door.
What happens on save
On a normal .gsx save, gsx runs this sequence:
Other project files have slightly different behavior:
- A
.go,go.mod, orgo.sumchange refreshes affected generation, then rebuilds and reloads. - A
.envchange restarts the existing backend with fresh environment values, then reloads. It does not regenerate or rebuild.
Saving while a build is running stops that build: its output is already out of date. gsx dev prints build superseded by newer changes, regenerates, and builds again. Go's build cache keeps the packages the stopped build finished, so the new build resumes rather than starting over. The browser is never reloaded onto a superseded build, so the next reload shows your latest save.
A .go save regenerates only the packages that depend on it and performs one in-place world reload rather than reopening the whole project. The reason appears in the terminal and the dev panel, e.g. full reload: changed Go source merge/merge.go.
When a build fails
After the server has built successfully once, generation and build errors from later save cycles appear in the browser overlay, and the last working server remains active. Fix the error and save again to build and reload the new version.
The first build
Before the first successful build, there is no last working server. Keep gsx dev running, fix the startup error, and save again.
Dev panel
Press Cmd-D (macOS) or Ctrl-D to toggle a status overlay with two buttons:
- Rebuild — full regenerate → build → restart → reload.
- Restart server — restart the Go server only.
Scaffolds ship it; existing apps add one line to their Vite client entry:
import "virtual:gsx-devpanel";(requires @gsxhq/vite-plugin-gsx ≥ 0.5.0; auto-show and the log box need ≥ 0.10.0; surviving body-swapping navigations such as htmx hx-boost needs ≥ 0.11.2). Disable it or rebind the key in vite.config.ts: gsx({ devPanel: false }) or gsx({ devPanel: { key: "k" } }).
The panel also auto-appears on its own once a cycle runs past about 3 seconds, so a slow rebuild surfaces without reaching for Cmd-D — tune the delay or turn it off with gsx({ devPanel: { autoShow: 5000 } }) or { autoShow: false }. While it's up, it shows the running phase with elapsed time and the last cycle's duration, and — when [dev].log is set — tails the backend log so you can watch build and server output without leaving the browser.
If Vite crashes, gsx dev restarts it automatically and pairs with the new process before trusting it again (plugin ≥ 0.7.0 — older plugins just suspend reload/overlay pushes instead) — refresh any tabs that were already open.
Customize the commands
Use the gsx dev flags for one-off changes to the front door, build, run, or logging commands. Put persistent settings in the [dev] section of gsx.toml.
The build command may start right after startup begins and be killed if startup regenerates files, so it must be safe to interrupt and re-run.