A lightweight static file server with live reload, written in C. No runtime dependencies beyond POSIX — just build and run.
- Serves static files over HTTP with correct MIME types
- Live reload via Server-Sent Events — browser refreshes automatically on file save
- Cross-platform: macOS (kqueue) and Linux (inotify)
- Colored, leveled logging with millisecond timestamps
- Fork-per-connection model, no event loop library needed
| Platform | Toolchain |
|---|---|
| Linux | gcc, make |
| macOS | clang (Xcode CLT), make, argp-standalone |
On macOS, install argp-standalone first:
brew install argp-standalonemake strip # release build (-O3)
make O_DEBUG=1 # debug build (-g3 -DDEBUG)The binary is placed at ./live-server.
sudo make strip install # installs to /usr/local/bin
sudo make strip install PREFIX=~/.local # installs to ~/.local/binTo uninstall:
sudo make uninstalllive-server [OPTIONS]| Option | Short | Default | Description |
|---|---|---|---|
--dir |
-I |
. |
Directory to serve |
--port |
-P |
8080 |
Port to listen on |
--host |
-H |
localhost |
Host to bind to |
--browser |
-B |
— | Browser to open automatically |
--log-level |
-L |
info |
Log level: error warn info debug |
--print-request |
-R |
— | Log each client request and headers |
Serve the current directory on the default port:
live-serverServe a build output folder on a custom port:
live-server -I ./dist -P 3000Open in browser automatically on startup:
live-server -I ./site -B open # macOS
live-server -I ./site -B xdg-open # LinuxExpose on the local network:
live-server -H 0.0.0.0 -P 8080Every served HTML page is automatically injected with a small <script> that holds open a persistent SSE connection to /livereload. When any file in the served directory changes, the watcher signals all connected browsers to call window.location.reload().
No browser extension or manual script tag needed — it's injected at serve time.
The watcher backend is selected at compile time:
- macOS —
kqueueviaEVFILT_VNODE - Linux —
inotifyviaIN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE
| Target | Description |
|---|---|
make |
Release build with -O3 |
make O_DEBUG=1 |
Debug build with -g3 -DDEBUG |
make install |
Install binary |
make uninstall |
Remove installed files |
make strip |
Strip debug symbols from binary |
make clean |
Remove build artifacts |
make help |
Show all targets |