Serve a folder.
Or just a file.
A small static file server, written in Rust.
Give it a path. Open your browser. Get on with it.
bunx dirjet public/index.htmlBefore the first npm release
The npm commands below describe the published package. Try it now from this repository with cargo run -- docs/.
Start with a directory or an HTML file. No config file required.
Run it in your terminal
Use Bun or npm after publishing. To run from the repository, choose Rust.
# Serve a directory
bunx dirjet public/
# Or a single HTML file
bunx dirjet example.htmlOpen localhost
Visit http://127.0.0.1:3000. That is the default address; the terminal prints the actual address when you choose another port.
Done? Press Ctrl + C
The server finishes active requests and shuts down.
Only Bun installed? Use bunx --bun dirjet public/. The default npm launcher uses Node.js 18+.
Point dirjet at your built site, a collection of files, or your current directory.
bunx dirjet public/Have an index.html? It is served when you open that directory.
No index file? Browse a directory listing with links to its visible files.
Relative assets work. Directory URLs redirect to a trailing slash.
Leave out the path to serve the current directory. Add --no-listing to return 404 when a directory has no index.
Preview a page without moving or renaming it. Both the root URL and the filename URL serve your chosen file.
bunx dirjet example.htmlGET /example.htmlGET /example.htmlexample.htmlGET /style.cssSibling stylesheetThe file's parent directory is the document root, so sibling files and assets in subdirectories are accessible by URL. Directory listings stay disabled in this mode.
Add --single or -s to return your entry HTML for missing extensionless routes. Your client-side router takes it from there.
bunx dirjet -s dist/GET /users/42index.html 200GET /missing.jsNot found 404Missing assets still return 404. With a file argument, -s uses that file as the entry. Startup fails if the required entry file is missing.
A path and a few switches. Defaults are enough for a local preview.
dirjet [OPTIONS] [PATH]PATH defaults to .| Option | Default | What it does |
|---|---|---|
-p, --port <PORT>Also -l, --listen | 3000 | Choose a TCP port. Use 0 for an available port. |
--host <IP> | 127.0.0.1 | Set the bind address. Use 0.0.0.0 for network access. |
-s, --single | Off | Fallback to the entry HTML for missing extensionless routes. |
--no-listing | Off | Return 404 for directories without index.html. |
-h, --help | n/a | Print command help. |
-V, --version | n/a | Print the installed version. |
Small changes for the way you work.
Use a different port-l
Choose a fixed port, or use --port 0 and read the selected port from the terminal.
bunx dirjet public/ -l 8080Open it to your local network--host
Bind to every network interface. On another device, use your serving machine's network address and the selected port.
bunx dirjet public/ --host 0.0.0.0Turn off directory listings--no-listing
Directories with an index still work. Directories without one return 404.
bunx dirjet public/ --no-listingRun with Bun, without Node.js--bun
Tell bunx to use Bun for the JavaScript launcher. The server itself runs as a native Rust executable.
bunx --bun dirjet example.htmlFiles stream from disk with content types inferred from their extensions.
- GET & HEAD
- Read files or request their headers. Other methods return 405.
- Byte ranges
- Range requests support partial downloads and media seeking.
- Cache revalidation
Cache-Control: no-cachemakes browsers revalidate. Last-Modified conditional requests can return 304.- Path handling
- Dotfiles, parent traversal, and symlinks resolving outside the document root are rejected.
Serve the build output. dirjet does not transpile TypeScript or JSX. It does not provide live reload, TLS, or full serve configuration compatibility.
The dirjet npm package launches the prebuilt binary for your platform. End users do not need Cargo or a Rust compiler.
dirjetSmall JavaScript launcherNative binaryDownloaded and cachedThe first run downloads only your OS and CPU binary from GitHub Releases, verifies its SHA-256 checksum, and caches it by version. Later runs reuse the cached binary. No postinstall scripts or Rust toolchain are needed. Linux binaries use musl.
The port is already in use
Choose another port with -l 8080 or let the operating system select one with --port 0. dirjet prints the resulting address.
The launcher cannot download a native binary
The first launch needs access to the matching GitHub release and a writable cache directory. Check the connection and retry; failed downloads are discarded. Use DIRJET_CACHE_DIR to choose another cache directory. For a source checkout, run cargo build --release first.
My TypeScript or JSX does not run
Build your application first, then serve its output directory. dirjet returns files as they are; it does not compile source code or bundle frontend assets.
A file returns 404
Check the document root and filename. Dotfiles and paths outside the root are unavailable. In SPA mode, missing files with extensions still return 404 instead of your entry HTML.