browser-b-gone
v0.1.0
Published
a connect middleware to reload the browser from the server
Downloads
3
Maintainers
Readme
browser-b-gone
A connect middleware to reload the browser from the server.
Usage with Express
First, import the build function from browser-b-gone and call it:
import { build } from "browser-b-gone";
const [reload, middleware] = build();
You will get back two functions:
reload
is a function you can call to reload the page in all connected browsers.middleware
is the Express middleware you need touse
Now, use the middleware:
app.use(middleware);
We do not inject anything into your HTML. You need to do that yourself.
You need to load the JavaScript file /reload
in your code (in development):
<script src="/reload" type="module"></script>
Now, whenever you call the reload()
function in your backend, the browsers
will reload.
Configuration
By default, browser-b-gone uses /reload
for serving the JavaScript and
delivering the change stream. You can change that by providing a different
endpoint:
const [reload, middleware] = build({
endpoint: "/my-reload"
});
If you do so, please remember to adjust your script tag accordingly:
<script src="/my-reload" type="module"></script>
Comparison to other solutions
- It has no dependencies and is very lightweight.
- It is easy to understand.
- It does not inject anything into your HTML.
- You can hook it into your code to reload on your behalf, sharing the watch process to be easy on your resources.
License
browser-b-gone is licensed under the Apache 2.0 License.