Registry / web-framework / tiny-lr-fork

tiny-lr-fork

JSON →
library0.0.5jsnpmunverified

tiny-lr-fork is an actively maintained fork of the original `tiny-lr` package, which had become unmaintained. It provides a lightweight, background-friendly LiveReload server implementation for development workflows. Unlike the original, this fork addresses lingering issues, incorporates community contributions, and includes security patches. Key differentiators include quieter operation (reduced `console.log` output), proper handling of WSS for `livereload.js` over HTTPS, and normalized Windows file paths. The server exposes a simple HTTP/WebSocket API that build tools (like Grunt, or custom scripts) can use to notify connected LiveReload clients (browser extensions or injected scripts) about file changes. It does not perform file watching itself, requiring external integration for detecting changes. The current stable version, as per the changelog, is 2.0.0, with a release cadence driven by bug fixes and necessary updates rather than a fixed schedule.

npm install tiny-lr-fork
INSTALL
IMPORT
SIG · TINY-LR-FORK
T
tiny-lr-fork
web-frameworkjavascriptv0.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tinylr
const tinylr = require('tiny-lr');
import tinylr from 'tiny-lr';
Primarily a CommonJS package. While Node.js supports ESM, its API is designed for `require()`.
tinylr.Server
const LiveReloadServer = require('tiny-lr').Server;
import { Server as LiveReloadServer } from 'tiny-lr';
The `Server` constructor is exposed directly on the main module export. The main export can also be called as a function `tinylr()` to create a server instance directly.
tinylr.middleware
const lrMiddleware = require('tiny-lr').middleware;
import { middleware as lrMiddleware } from 'tiny-lr';
Used to integrate tiny-lr as a Connect/Express middleware. It should be used after body parsing and query parsing middleware.

This quickstart demonstrates how to set up `tiny-lr-fork` as a standalone LiveReload server integrated with an Express application, listening on the default port 35729. It shows both starting the server and integrating its middleware for handling reload requests, along with an example of a custom route. It also includes `curl` commands to trigger reloads.

const tinylr = require('tiny-lr'); const path = require('path'); const express = require('express'); const PORT = 35729; // Standard LiveReload port for browser extensions const app = express(); // Initialize tiny-lr server const lrserver = tinylr(); // Listen for specific requests on the tiny-lr server (optional) lrserver.on('GET /custom-status', (req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('tiny-lr server is running and custom route works!'); }); // Integrate tiny-lr middleware with Express // In modern Express, query parsing is built-in, but body-parser might still be needed. app.use(express.json()); // For POST requests with JSON body app.use(express.urlencoded({ extended: true })); // For URL-encoded bodies app.use(lrserver.middleware({ app: app })); // Bind tiny-lr routes to the Express app // Serve static files (e.g., your project's root) app.use(express.static(path.resolve('./'))); // Start the Express app and tiny-lr server app.listen(PORT, function() { console.log(`Express app and tiny-lr server listening on port ${PORT}`); console.log('Use `curl http://localhost:35729/changed?files=index.html` to trigger reloads.'); console.log('Or `curl -X POST http://localhost:35729/changed -d "{\"files\":[\"style.css\"]}"`'); }); // Example of how to trigger a reload programmatically // setTimeout(() => { // lrserver.changed({ body: { files: ['index.html'] } }); // console.log('Triggered a reload after 5 seconds.'); // }, 5000);
Debug
Known issues
breakingVersion 2.0.0 of tiny-lr-fork, alongside its dependency `livereload-js`, has officially dropped support for Internet Explorer versions 6 through 9. Projects targeting these legacy browsers will experience issues.
fix
Upgrade client-side browser versions or ensure your development setup does not require LiveReload functionality for IE6-9.
affects: >=2.0.0
gotchaWhen integrating `tiny-lr` as Connect/Express middleware, it requires query and body parsing middleware to be registered *prior* in the stack for POST requests to `/changed` to work correctly. For modern Express, `express.json()` and `express.urlencoded()` are needed.
fix
Ensure `app.use(express.json());` and `app.use(express.urlencoded({ extended: true }));` (or equivalent parsing middleware) are registered *before* `app.use(tinylr.middleware({ app: app }));`.
affects: >=1.0.0
gotchaThe LiveReload browser extensions (Chrome, Firefox, Safari) by default connect to port `35729`. If you configure `tiny-lr-fork` to listen on a different port, the browser extension will not automatically connect. You will need to manually configure the extension or inject the `livereload.js` script with the correct port.
fix
For seamless browser extension integration, run `tiny-lr-fork` on port 35729. If a different port is necessary, manually edit the LiveReload browser extension's settings or use the manual script tag injection method with a `port` attribute in your HTML: `<script src="http://localhost:YOUR_PORT/livereload.js?snipver=1"></script>`.
affects: >=1.0.0
gotcha`tiny-lr-fork` is a server that *receives* reload notifications and broadcasts them. It does not include built-in file watching capabilities. You must use an external build tool (e.g., Gulp, Webpack, or a simple `fs.watch` script) to detect file changes and then notify `tiny-lr-fork`.
fix
Integrate with a file watcher in your build process. Upon file change detection, send an HTTP request to `http://localhost:35729/changed?files=your_file.css` or a POST request with a JSON payload to the `/changed` endpoint.
affects: >=1.0.0
deprecatedPrevious versions of `tiny-lr-fork` (and its original `tiny-lr` predecessor) had vulnerabilities in the `debug` and `qs` dependencies. While these have been patched in recent releases, it's crucial to stay updated.
fix
Always upgrade to the latest stable version of `tiny-lr-fork` to ensure all known security vulnerabilities in its dependencies are addressed. Current stable is >=2.0.0.
affects: <1.1.1
Errors
Common errors & fixes
Error: listen EADDRINUSE: address already in use :::35729
Another process, or a previous instance of your `tiny-lr-fork` server, is already listening on the specified port (default 35729).
fix
Stop the conflicting process, or configure `tiny-lr-fork` to listen on a different port using the `-p` or `--port` command line option, or by passing a `port` option to `tinylr().listen(port, ...)`.
WebSocket connection to 'ws://localhost:35729/livereload' failed: Error during WebSocket handshake: Unexpected response code: 404
The `tiny-lr-fork` server is either not running, or its middleware is not correctly mounted in your application stack, leading to the `/livereload` path not being handled.
fix
Ensure your `tiny-lr-fork` server is running. If using it as middleware, verify `app.use(lrserver.middleware({ app: app }));` is correctly placed in your Connect/Express application and the `app` object is the same as the one listening on the port.
TypeError: app.use() requires a middleware function but got a undefined
This typically occurs when `express.bodyParser()` or `express.query()` are referenced as middleware in older examples, but are either not imported or are deprecated in your version of Express.
fix
For modern Express (4.x+), use `app.use(express.json());` and `app.use(express.urlencoded({ extended: true }));` to handle body and query parsing before the `tiny-lr-fork` middleware.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
connectoptionalCommonly used as a middleware host, though not a direct runtime dependency of the core server.
expressoptionalCommonly used as a middleware host, though not a direct runtime dependency of the core server.
livereload-jsrequiredThe client-side script that connects to the tiny-lr server. Implicitly relied upon for functionality.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources