2.0.0 • Published yesterdayCLI
@tb.p/serve-media
Licence
MIT
Version
2.0.0
Deps
0
Size
37 kB
Vulns
0
Weekly
0
@tb.p/serve-media
Spin up a local single-page media browser for any directory:
npx @tb.p/serve-media <path>
- Explorer-style folder tree on the left — only folders that (recursively) contain media are shown, with item counts. Clicking a folder shows all media under it, recursively.
- Tile grid on the right — images and videos only; everything else is ignored.
- Resizable tiles — toolbar slider or
Ctrl+ mouse wheel, just like Windows Explorer. - Videos stream with range-request support, show duration, and play on hover; click any tile for a full-size lightbox (arrow keys /
Esc). - Filter by name, sort by name / newest / oldest / largest / shuffle.
- A status bar lists the extensions of files that were not served in the current folder (recursively), with counts — so you always know what was skipped.
- Draggable sidebar splitter; tile size and sidebar width persist across sessions.
- Single viewer, self-terminating — only one page may connect at a time (others get a "busy" page). Once the viewer connects, closing that page shuts the server down; no orphaned servers left running. Refreshing the page is fine (5-second grace window). Disable with
--no-exit.
Recognized extensions — images: jpg jpeg jfif png apng gif webp avif bmp svg ico; video: mp4 m4v webm mov mkv ogv ogg 3gp. This is the set latest Chrome renders natively; formats Chrome can't decode (heic, tiff, jxl, avi, wmv, …) are intentionally excluded so they don't appear as broken tiles. Note containers like mov/mkv still depend on the codec inside (H.264/VP9/AV1 play; e.g. ProRes won't).
Options
serve-media [path] [options]
path Directory to serve (default: current directory)
-p, --port <n> Port (default: 4321; auto-increments if busy)
--host <host> Host to bind (default: 127.0.0.1)
--no-open Don't open the browser automatically
--no-exit Allow multiple viewers; keep running after the page closes
Zero dependencies. Binds to 127.0.0.1 by default, so it is only reachable from this machine; pass --host 0.0.0.0 to expose it on your LAN.
Publish
npm publish --access public