Node.js module to refresh and reload your code in your browser when your code changes.
—
The reload CLI provides a standalone development server with automatic browser refresh capabilities. It serves static files, watches for changes, and automatically injects reload functionality into HTML pages without requiring code modifications.
Start a development server with reload functionality.
reload [options]Usage Examples:
# Basic usage - serves current directory on port 8080
reload
# Serve specific directory
reload -d ./public
# Custom port
reload -p 3000
# Open browser automatically
reload -bAutomatically open the application in the default browser.
-b, --browserUsage Examples:
# Open browser automatically
reload -b
# Open browser with custom hostname
reload -b -n myapp.local
# Open browser with specific port
reload -b -p 3000Configure the hostname for browser opening and server binding.
-n, --hostname [hostname]Default: localhost Usage: Customize the hostname used when opening the browser automatically.
Usage Examples:
# Use custom hostname
reload -b -n myapp.local
# Use IP address
reload -b -n 192.168.1.100Configure which directory to serve as the web root.
-d, --dir [dir]Default: Current working directory Usage: Specify the directory containing your HTML, CSS, and JavaScript files.
Usage Examples:
# Serve public directory
reload -d ./public
# Serve build output
reload -d ./dist
# Serve nested directory
reload -d ./src/webConfigure which directory to monitor for file changes.
-w, --watch-dir [watch-dir]Default: Same as serving directory Usage: Watch a different directory than the one being served (useful for compiled assets).
Usage Examples:
# Watch source directory while serving build directory
reload -d ./dist -w ./src
# Watch multiple levels
reload -w ./src/scssConfigure which file types trigger server restart and browser reload.
-e, --exts [extensions]Default: html,js,css Format: Comma-separated or pipe-separated list Usage: Specify which file extensions should be monitored for changes.
Usage Examples:
# Watch additional file types
reload -e "html,js,css,json,md"
# Watch only specific types
reload -e "html,css"
# Use pipe separator
reload -e "html|js|css|ts"Configure the server port.
-p, --port [port]Default: 8080 Environment Variable: Can also be set via PORT environment variable Usage: Set the port for the HTTP server.
Usage Examples:
# Custom port
reload -p 3000
# Use environment variable
PORT=4000 reload
# High port number
reload -p 8888Configure the default page to serve and open in the browser.
-s, --start-page [start-page]Default: index.html Usage: Specify the filename to use as the default page.
Usage Examples:
# Use different start page
reload -s main.html
# Use nested start page
reload -s pages/home.htmlEnable fallback to the start page for single-page applications.
-f, --fallback [fallback]Default: false Usage: Enable fallback routing for SPAs where all routes should serve the start page.
Usage Examples:
# Enable fallback routing
reload -f
# Combine with custom start page
reload -f -s app.htmlEnable detailed logging for debugging.
-v, --verbose [verbose]Default: false Usage: Enable verbose logging on both server and client sides.
Usage Examples:
# Enable verbose logging
reload -v
# Combine with other options
reload -v -b -p 3000Display the current version of reload.
-V, --versionUsage Example:
reload --versionDisplay usage information and available options.
-h, --helpUsage Example:
reload --help# Serve current directory with browser auto-open
reload -b
# Serve specific directory with custom port
reload -b -d ./public -p 3000
# Watch source files while serving build output
reload -b -d ./dist -w ./src -e "html,js,css,scss"# Enable fallback routing for SPA
reload -b -f -s index.html
# SPA with custom configuration
reload -b -f -s app.html -p 4000 -d ./build# Comprehensive development server
reload -b -v -d ./public -w ./src -e "html,js,css,json,md" -p 3000 -n localhostThe CLI server provides static file serving with the following features:
index.html and index.htm from directories.html extension resolution for extensionless URLsThe server automatically injects the reload client script into HTML files:
<!-- Automatically injected by reload -->
<script src="/reload/reload.js"></script>
<!-- End Reload -->This injection happens for:
.html files/).html filesFile watching is handled by the supervisor package with the following behavior:
The CLI server uses the same WebSocket system as the Express integration:
The CLI server is managed by the supervisor package:
# The CLI internally runs something equivalent to:
supervisor -e "html,js,css" -w ./src -q -- reload-server.js [args...]This provides:
Install with Tessl CLI
npx tessl i tessl/npm-reload