FILES → LOCALHOST

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.

Native binariesDistributed through npmMIT license
ONE COMMAND. YOUR FILES, SERVED.COMMAND PREVIEW
bunx dirjet public/
ON DISK
public/
├─ index.html
├─ style.css
└─ assets/
IN YOUR BROWSER127.0.0.1:3000/
200index.html
Your index file, ready to view.

Before the first npm release
The npm commands below describe the published package. Try it now from this repository with cargo run -- docs/.

01

Up and serving

#

Start with a directory or an HTML file. No config file required.

1

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.html
2

Open localhost

Visit http://127.0.0.1:3000. That is the default address; the terminal prints the actual address when you choose another port.

3

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+.

02

A directory becomes a website

#

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.

03

Just one HTML file? That works.

#

Preview a page without moving or renaming it. Both the root URL and the filename URL serve your chosen file.

bunx dirjet example.html
GET /example.html
GET /example.htmlexample.html
GET /style.cssSibling stylesheet

The 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.

04

Let your app handle the route

#

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 200
GET /missing.jsNot found 404

Missing assets still return 404. With a file argument, -s uses that file as the entry. Startup fails if the required entry file is missing.

05

The whole CLI

#

A path and a few switches. Defaults are enough for a local preview.

dirjet [OPTIONS] [PATH]PATH defaults to .
dirjet command-line flags and their defaults
OptionDefaultWhat it does
-p, --port <PORT>Also -l, --listen3000Choose a TCP port. Use 0 for an available port.
--host <IP>127.0.0.1Set the bind address. Use 0.0.0.0 for network access.
-s, --singleOffFallback to the entry HTML for missing extensionless routes.
--no-listingOffReturn 404 for directories without index.html.
-h, --helpn/aPrint command help.
-V, --versionn/aPrint the installed version.
06

A few useful variations

#

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 8080
Open 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.0
Turn off directory listings--no-listing

Directories with an index still work. Directories without one return 404.

bunx dirjet public/ --no-listing
Run 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.html
07

What happens on a request

#

Files 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-cache makes 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.

08

Rust inside. npm outside.

#

The dirjet npm package launches the prebuilt binary for your platform. End users do not need Cargo or a Rust compiler.

dirjetSmall JavaScript launcher
Native binaryDownloaded and cached
Linux x64 · ARM64macOS x64 · ARM64Windows x64 · ARM64

The 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.

09

If something gets in the way

#
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.

Back to the beginning

Jump to a section

Documentation