An extremely small Linux-only static dev server written in C++.
  • C++ 98.3%
  • CMake 1.7%
Find a file
theo 8f0a3fcfec
All checks were successful
Forgejo CMake CI / build (clang, clang++) (push) Successful in 38s
Forgejo CMake CI / build (gcc, g++) (push) Successful in 56s
fix builds failing on forgejo
2026-07-09 11:43:02 +01:00
.forgejo/workflows remove tests from workflow 2026-07-09 11:38:30 +01:00
.github/workflows first commit 2026-07-06 23:41:07 +01:00
external first commit 2026-07-06 23:41:07 +01:00
src fix builds failing on forgejo 2026-07-09 11:43:02 +01:00
.gitignore setup for .deb releases 2026-07-08 21:49:15 +01:00
CMakeLists.txt add config support 2026-07-09 11:00:44 +01:00
LICENSE first commit 2026-07-06 23:41:07 +01:00
README.md add config support 2026-07-09 11:00:44 +01:00

liveserver

An extremely small Linux-only static dev server written in C++.

It serves a directory, picks an available port, injects a browser reload client into HTML files, watches files for changes, and refreshes connected browsers over a WebSocket.

CSS changes are reloaded by swapping stylesheet links. Other changes cause a full page refresh.

Build

cmake -S . -B build
cmake --build build

The compiled binary is created at build/liveserver.

Install

Install to the default CMake prefix:

sudo cmake --install build

Usage

Serve the current directory:

liveserver

Serve a specific directory:

liveserver ./dist

Choose a preferred port:

liveserver ./dist --port 5173

If that port is busy, liveserver automatically tries the next available port. Use --strict-port to fail instead.

Bind to a specific host:

liveserver ./dist --host 0.0.0.0

Open the browser automatically:

liveserver ./dist --open

Options

Usage: liveserver [directory] [options]

Options:
  --port <port>          Preferred port (default: 3000)
  --host <addr>          Bind host (default: 127.0.0.1)
  --config <path>        The path to load the liveserver config from
  --strict-port          Fail if --port is unavailable
  --open                 Open the served URL in the default browser
  --spa                  Fallback unknown paths to index.html
  --ignore <glob>        Ignore file watcher paths (repeatable)
  --disable-logging      Disable console logging
  --verbose              Show low-level connection logs
  --no-color             Disable ANSI colors
  --no-live-reload       Disable file watching and browser refresh
  --poll <ms>            File watch poll interval (default: 250)
  --version              Show version
  --help                 Show help

Config

liveserver tries to load liveserver.json from the current directory. You can also pass a custom config path with --config.

liveserver --config ./server.json

CLI options override values from the config file. Example liveserver.json:

{
    "root": "./dist",
    "port": 5173,
    "host": "0.0.0.0",
    "openBrowser": true,
    "spaFallback": true,
    "pollMs": 250,
    "ignore": [".cache", "node_modules"]
}

License

This project is licensed under the MIT License. See LICENSE.