Socket
Book a DemoInstallSign in
Socket

express-browser-reload

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-browser-reload

✨ Node.js module to refresh your browser when your Express server restarts.

4.0.0
latest
Source
npmnpm
Version published
Weekly downloads
163
328.95%
Maintainers
1
Weekly downloads
 
Created
Source

express-browser-reload

npm

Node.js module to refresh your browser when your Express server restarts. Works by using a WebSocket to the server and waits for the WebSocket to close to detect the server restarting. Once the server comes back up, the page will be reloaded.

This project is a hard fork of reload, which is a more generalized tool with more features beyond the Express world. This fork is maintained by the Roosevelt web framework team, but it can be used independently of Roosevelt as well.

Usage

const express = require('express')
const app = express()

app.get('/', function (req, res) {
  res.type('text/html')
  res.send(`<!doctype html>
<html>
  <head>
    <title>express-browser-reload express sample</title>
  </head>
  <body>
    <p>express-browser-reload express sample</p>
    <!-- all you have to do is include the reload script and have it be on every page of your project -->
    <!-- you do not create this route, reload creates it for you automatically -->
    <script src="/express-browser-reload.js"></script>
  </body>
</html>`)
})

const server = app.listen(3000, () => console.log(`🎧 express-browser-reload express sample app server is running on http://localhost:3000`))

const params = {
  route: '/express-browser-reload.js',
  skipDeletingConnections: false
}

require('express-browser-reload')(app, server, params)

Params API:

  • route: What Express route to put the client-side JS file on. Default: /express-browser-reload.js.
  • skipDeletingConnections: Whether to skip purging HTTP connections on the Express server when it restarts. If you're already handling this on your Express server yourself, set this param to true to prevent errors.

Keywords

reload

FAQs

Package last updated on 01 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.