browser-b-gone

0.1.0 • Public • Published

browser-b-gone

npm

A connect middleware to reload the browser from the server.

TV-B-Gone is a remote to turn off any TV

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 to use

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.

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i browser-b-gone

    Weekly Downloads

    2

    Version

    0.1.0

    License

    Apache-2.0

    Unpacked Size

    21.1 kB

    Total Files

    14

    Last publish

    Collaborators

    • moonglum