New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fastify-live-refresh

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

fastify-live-refresh

This package is a quick and easy way to refresh the browser from the server so you can see live updates whenever you save your files.

unpublished
beta
latest
npmnpm
Version
0.0.1-beta.1
Version published
Maintainers
0
Created
Source

fastify-live-refresh

This package is a quick and easy way to refresh the browser from the server so you can see live updates whenever you save your files.

Tech Summary

Auto-injecting WebSocket client for Fastify that enables live reloading of the browser.

Usage

import  fastifyWebsocket  from  '@fastify/websocket';
import { FastifyLiveRefresh } from  'fastify-live-refresh'

app.register(fastifyWebsocket);
const  liveRefresh  =  new  FastifyLiveRefresh(app);

You must trigger the live refresh yourself, this lets the package be unopinionated. You choose when to run the refresh() method and the client will be updated. I tend to just run a file watcher with chokidar.

Suggested Usage

if(isDev)
{

	app.register(fastifyWebsocket);

	const  liveRefresh  =  new  FastifyLiveRefresh(app);

	chokidar.watch(publicDir, { ignoreInitial:  true }).on("all", (event, filePath) => {

	liveRefresh.refresh()

	});
}

Overview

This will set up a WebSocket for you with zero configuration and it will automatically inject and serve the needed client-side JS so it just works like magic.

  • Zero Configuration: Just create an instance and pass it your Fastify app.

  • Self-Contained: No need for extra setup—just install and use.

Installation


npm  install  fastify-live-refresh

Features

  • Auto-injects the WebSocket client into HTML pages

  • Serves the client-side script automatically

  • Works out-of-the-box with Fastify

  • No dependencies beyond Fastify itself

  • Minimalist API, no complex configuration needed

Configuration (Optional)

By default, the WebSocket server runs at:

  • Route: /ws-HOT-CLIENT-FASTIFY-RESERVED-ROUTE

  • Script URL: /AUTO-INJECTED-BY-HOT-CLIENT-FASTIFY.js

You can override the route in the constructors options


new  HotClientFastify(fastify, { route:  '/my-custom-ws-route' });

Minimal Package

This package is intended to save a few hours of research and experimentation to rebuild this functionality in each web app I make. Its scope is small enough that it is currently complete outside of being battle-tested and will most likely not receive any further updates unless major infrastructure changes occur to Fastify.

Keywords

fastify

FAQs

Package last updated on 14 Feb 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