nano-web

Crates.ionano-web
lib.rsnano-web
version1.1.6
created_at2025-08-07 11:49:02.291558+00
updated_at2026-01-12 15:28:05.103812+00
descriptionStatic file server built with Rust with pre-compressed in-memory caching
homepagehttps://github.com/radiosilence/nano-web
repositoryhttps://github.com/radiosilence/nano-web
max_upload_size
id1785167
size174,924
James Cleveland (radiosilence)

documentation

https://docs.rs/nano-web

README

nano-web

CI Build Crates.io License: MIT

Static file server. Pre-loads and pre-compresses all files at startup for near-zero latency serving.

Performance

  • Raw hyper (no framework overhead)
  • SO_REUSEPORT for multi-core scaling
  • Files pre-compressed at startup (brotli/gzip/zstd)
  • Lock-free concurrent routing (DashMap + FxHash)
  • Zero-copy responses (Bytes)

Benchmark (M3 Max):

wrk -c 50 -d 10 -t 50 http://localhost:3000
Requests/sec: 149838.48
Latency: 328.63us avg

Install

# mise
mise install ubi:radiosilence/nano-web

# cargo
cargo install nano-web

Pre-built binaries on GitHub Releases.

Docker

FROM ghcr.io/radiosilence/nano-web:latest
COPY ./dist /public/

Usage

nano-web serve                          # ./public on :3000
nano-web serve ./dist --port 8080       # custom dir/port
nano-web serve --spa --dev              # SPA mode + hot reload

Options

Flag Default Description
--port, -p 3000 Port
--spa false Serve index.html for unknown routes
--dev, -d false Reload modified files
--config-prefix VITE_ Env var prefix for template injection
--log-level info debug/info/warn/error
--log-format console console/json
--log-requests false Log each request

Runtime Config Injection

Inject env vars into HTML at startup:

<script>
  window.ENV = JSON.parse("{{EscapedJson}}");
</script>

Variables: {{env.VAR_NAME}}, {{Json}}, {{EscapedJson}}

Health Check

/_health returns {"status":"ok","timestamp":"..."}

License

MIT

Commit count: 381

cargo fmt