webserve
Static file server for local development — SPA fallback, optional live reload, configurable host and port.
Repository · Issues · Pull requests
Features
| Capability | Description |
|---|---|
| Static hosting | Serve any folder; directory listing when no index.html is present |
| Directory listing UI | Full-width layout, breadcrumbs, folders first then files; name, size, modified; light/dark theme with icon toggle (persisted) |
| SPA mode | --spa — unknown paths serve index.html (client-side routing) |
| Live reload | --watch — filesystem watcher + injected reload script for HTML |
| Open browser | --open — after bind, open default browser (uses 127.0.0.1 when host is 0.0.0.0) |
| URL normalization | Collapses // and . segments; directory URLs get a trailing / redirect (disable with --no-redirect-dir-slash) |
| Binding | Configurable --host and --port (defaults: 127.0.0.1, 8080); if port is in use, tries next port until one is free |
Requirements
- Rust (stable), e.g. via rustup
Installation
From a clone
Binary: target/release/webserve (or webserve.exe on Windows).
Install into Cargo bin path
Install from registry*
Usage
Run webserve --help for the full option list.
Options
| Option | Short | Description | Default |
|---|---|---|---|
--dir |
-d |
Root directory to serve | Current working directory |
--port |
-p |
TCP port | 8080 |
--host |
-h |
Bind address | 127.0.0.1 |
--spa |
— | SPA fallback to index.html |
off |
--watch |
-w |
Watch files and reload browsers | off |
--open |
— | Open default browser to server URL | off |
--no-redirect-dir-slash |
— | Don’t redirect /dir → /dir/ |
off (redirect on) |
Examples
Serve the current directory:
Serve a production build with SPA and reload (typical for Vite/React/Vue dist):
Open the site in the browser after start:
Listen on all interfaces (e.g. phone on same LAN):
Development
Git hooks (tag + version check): use the repo’s hooks directory (native core.hooksPath):
Hooks are off by default so git push isn’t delayed. Optional tag check: WEBSERVE_HOOK_VERSION_CHECK=1 git push origin v1.2.1 — see .githooks/README.md.
License
MIT © Mark Wayne Menorca