livesync

Automatically reloads the page as soon as a change is detected.

Usage no npm install needed!

<script type="module">
  import livesync from 'https://cdn.skypack.dev/livesync';
</script>

README

livesync

Automatically reloads the page as soon as a change is detected.

Usage

Quite simple, actually, here's how to use it in express.js

In Node

var express = require("express"),
    app = express(),
    livesync = require("livesync"),
    live = new livesync();

app.use(express.static(__dirname + "/static"));
live.watch(__dirname + "/static");

app.listen(8080);

In HTML, you just add socket.io and livesync.

<script src="http://127.0.0.1:46281/socket.io/socket.io.js"></script>
<script src="http://127.0.0.1:46281/socket.io/livesync.js"></script>

Alternatively, to keep it all in one port,

In Node

var express = require("express"),
    app = express(),
    server = require("http").createServer(app),
    io = require("socket.io").listen(server),
    livesync = require("livesync"),
    live = new livesync(io);

app.use(express.static(__dirname + "/static"));
app.use(live.middleware());

server.listen(8080);

In HTML, you just add socket.io and livesync.

<script src="/socket.io/socket.io.js"></script>
<script src="/socket.io/livesync.js"></script>