$ show alallier/reload
Reload is a Node.js library and CLI tool that automatically refreshes web pages in the browser when server-side code changes. It works by injecting a client-side JavaScript file that opens a WebSocket connection to the server. When the server restarts (or a manual reload event is triggered), the WebSocket closes, the client detects the closure, waits for the server to come back up, and then reloads the page. The library integrates with Express applications by creating a route to serve the client script, while the CLI tool serves static files and uses nodemon to watch for file changes. The core logic is in `lib/reload.js`, which handles WebSocket server setup, HTTPS support, and parameter validation. The client-side script (`lib/reload-client.js`) is a self-contained pattern that can be reused in other projects. The codebase is well-tested, actively maintained, and follows modern JavaScript practices.
The LLM identified 1 files worth highlighting for reuse:
A self-contained client-side JavaScript file that establishes a WebSocket connection to the reload server and automatically reloads the page when the connection is lost and re-established. It handles edge cases such as preventing infinite reload loops on initial page load and short-circuiting reload when the user navigates away. The script can be easily extracted and used in any web project by adjusting the port and forceWss variables. It demonstrates a robust pattern for WebSocket-based live reloading.