devserve is a small development webserver with built-in live-reloading for HTML files.
- Serve static files from specified directory (or CWD by default)
- Watch files for changes
- Automatically reload HTML files
- Hot-reload CSS changes (no page reload)
HTML files are served with this script injected just before </body>.
It sets up the page to listen for server-sent events on /events
The server watches files for any changes and notifies via event: change events on the /events endpoint.
Any other files and directories are served by http.ServeFile directly.
$ go install github.com/czak/devserve@latestBy default devserve will serve files from current directory on :8080:
$ devserve
2025/03/27 16:00:34 Serving files from "." on ":8080"Directory and address can be overridden with -dir and -addr respectively:
$ devserve -dir public -addr "127.0.0.1:3000"
2025/03/27 16:01:25 Serving files from "public" on "127.0.0.1:3000"All flags:
$ devserve -h
Usage of devserve:
-addr string
network address (default ":8080")
-dir string
directory to serve from (default ".")- Should work on all Go platforms, but only tested on Linux
CSS hot reloading code was taken from https://esbuild.github.io/api/#hot-reloading-css