Dev Server (Live Reload)¶
gmx dev is the development counterpart to gmx run. It compiles and launches
your app, then watches your component and all of its .gmx dependencies. On
every change it rebuilds and, when the build succeeds, restarts the app and
reloads the browser automatically — no manual rebuild, no manual refresh.
gmx dev app.gmx
│
├── compiles app.gmx → temporary binary
├── runs it on a random free port
├── serves a proxy on :8080 (public)
│ └── injects a live-reload script into every HTML page
└── watches app.gmx + every imported .gmx
└── on change → rebuild → restart → reload browser
How it works¶
gmx dev runs your app behind a small reverse proxy:
- The proxy listens on the public port (default
:8080) and forwards requests to your app, which runs on a random free port. - Live reload is injected automatically. The proxy adds a tiny
EventSourceclient to every HTML response that connects to the/__gmx_reloadendpoint. When a rebuild succeeds, the proxy pushes a reload event and the browser callslocation.reload(). - Dependency watching is recursive. If
app.gmximportscomponents/TaskItem.gmx, which importscomponents/Badge.gmx, all three are watched. Saving any of them triggers a rebuild. - Debouncing coalesces bursts of file events (editors often write a file several times per save) into a single rebuild.
Error overlay¶
When a build fails — a syntax error, a type error, anything the compiler or
go build rejects — the previously running app is left untouched so you
never lose your session. The browser instead shows a readable overlay with the
compiler output:
Fix the error and save; the next successful build clears the overlay and reloads the page automatically.
Flags¶
| Flag | Default | Description |
|---|---|---|
--port N |
8080 |
Public port for the dev server. |
Run gmx dev -h for the full usage message.
Choosing the app port¶
The compiled app reads the PORT environment variable and falls back to 8080
when it is unset — so gmx build and gmx run are unchanged. gmx dev uses
this to run your app on a random free port behind the proxy. You can rely on the
same variable in production:
Clean shutdown¶
Press Ctrl-C (or send SIGINT/SIGTERM). gmx dev stops the child process —
and its whole process group — before exiting, so no orphaned server is left
holding the port.
When to use gmx run vs gmx dev¶
gmx run |
gmx dev |
|
|---|---|---|
| Rebuild on change | ❌ | ✅ |
| Browser live reload | ❌ | ✅ |
| Compile-error overlay | ❌ | ✅ |
| Reverse proxy | ❌ | ✅ |
| Best for | one-off runs | active development |