tiny-lr is a minimalist LiveReload server implementation designed for integration into build workflows. It provides an HTTP server and Express middleware with a simple REST API to broadcast file change notifications to connected LiveReload clients. Unlike comprehensive live-reloading solutions, tiny-lr does not include file watching capabilities itself; users must integrate it with an external file watcher (e.g., from a build tool like Gulp or Grunt). The current stable version is 2.0.0, which marked a return to active development after a period of dormancy, focusing on dependency updates and modern browser compatibility. Its primary differentiators are its focused scope (only serving reload notifications), ease of integration into existing build chains, and low overhead, making it suitable for projects that prefer to manage file watching separately.
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
tiny-lr primarily uses CommonJS `require` syntax. As of v2.0.0, there is no official ESM support. The default export is a factory function that returns a server instance.
const tinylr = require('tiny-lr');
The `Server` class can be accessed directly for more explicit instantiation, though the default `tinylr()` factory is more common. Still CommonJS only.
const LiveReloadServer = require('tiny-lr').Server;
The Express/Connect middleware is a named export available on the main `tiny-lr` module. It requires `body-parser` to be used earlier in the middleware stack for handling POST requests.
const livereloadMiddleware = require('tiny-lr').middleware;
This quickstart demonstrates setting up a tiny-lr server on its standard port and integrating its middleware with an Express application. It also shows how to programmatically trigger a file change notification to connected LiveReload clients.
const tinylr = require('tiny-lr');
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const port = process.env.LR_PORT || 35729; // Standard LiveReload port
const app = express();
// Start the LiveReload server independently
const lrServer = tinylr();
lrServer.listen(port, function() {
console.log(`LiveReload server listening on port ${port} (for browser extensions).`);
});
// Or integrate as Express middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(tinylr.middleware({ app: app }));
app.use(express.static(path.resolve('./public'))); // Serve static files
app.get('/', (req, res) => {
res.send('<h1>Hello from tiny-lr!</h1><p>Check the browser console or network tab for livereload.js.</p>');
});
// Example of triggering a reload via HTTP API
// This would typically be called by a build tool when files change.
// curl http://localhost:35729/changed?files=index.html,style.css
// curl -X POST http://localhost:35729/changed -d '{ "files": ["script.js"] }'
app.listen(8000, () => {
console.log('Express server listening on port 8000.');
console.log('Open http://localhost:8000 in your browser and ensure LiveReload extension is active or script tag is added.');
console.log('To trigger a reload, send a POST request to http://localhost:35729/changed with a JSON body: { "files": ["index.html"] }');
});
// To manually trigger a reload (e.g., from your file watcher)
function notifyChange(files) {
lrServer.changed({ body: { files: files } });
console.log('Notified LiveReload clients about:', files);
}
// Simulate a file change after 5 seconds
setTimeout(() => {
notifyChange(['index.html', 'style.css']);
}, 5000);
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.