Serve file or folder as a web-page.
mise install github:dector/serve
serve --versionserv README.md
serv DownloadsDefault port: 8080.
To use a specific port, pass --port/-p:
serv -p 3000 README.mdIf the requested port is unavailable, serv automatically picks another free port.
Use --expose-tailscale/-T to expose the local server with Tailscale Serve. The tailscale CLI must be installed and configured.
serv -T README.md
serv --expose-tailscale Downloads
serv -T 443 README.md
serv -p 3000 -T 443 README.mdWhen -T is used without a value, serv chooses a seeded-random high local port and uses the same HTTPS port for Tailscale. Passing a value to -T sets the Tailscale HTTPS port only; --port/-p sets the local backend port only.
With Tailscale exposure enabled, the local server binds to 127.0.0.1 instead of all interfaces. If an explicit local port is busy, serv fails instead of choosing another port.
Use --open/-o to open the served URL in your default browser after the server starts:
serv --open README.md
serv -o DownloadsBrowser opening is best-effort; if it fails, the server keeps running and prints the URL.
serv defaults to preview mode, optimized for reading repos and websites:
serv .
serv README.mdIn preview mode, supported Markdown files (.md, .markdown, .mdown, .mkd) render as HTML. Directories resolve README first, then index.html, then fall back to a listing. Auto-resolved README previews include a foldable side menu for navigating sibling files and folders.
Use file mode for raw file browsing:
serv --mode file Downloads
serv -m f DownloadsIn file mode, files are served raw and directories show listings by default.
Change directory resolution with --dir-resolve:
serv --mode preview --dir-resolve index-first site
serv -m p --dir-resolve rf .
serv -m file --dir-resolve index-only siteStrategies: readme-first/rf, index-first/if, readme-only/ro, index-only/io, none/n.
Per-request URL overrides:
/README.md?raw=1
/README.md?preview=1
/docs/?resolve=none
/docs/?resolve=index-only
- You can serve either a directory or a single file.
- HTML files are served directly as static HTML.
- Missing directory resolution candidates fall back to a directory listing.
--preview/-Pis deprecated; use--mode preview.--no-index-resolveis deprecated; use--dir-resolve.
Discributed using MIT license.