fastify-refresh
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

fastify-refresh

Gradually restores Fastify's MP. +3mp/tick


A zero-config, automatic browser refresh tool for Fastify.
Designed for seamless live updates while developing your front-end.


npm version npm downloads License

Github: https://www.github.com/alexstevovich/fastify-refresh.

Tech Summary: FastifyRefresh automatically injects a WebSocket client to enable live browser refresh—no setup required.


Usage

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

// Register WebSockets
app.register(fastifyWebsocket);

// Create FastifyRefresh instance
const fastifyRefresh = new FastifyRefresh(app);

// Trigger refresh manually when needed
fastifyRefresh.refresh();

You decide when you trigger the refresh. I usually just trigger it with something like chokidar:

Suggested Usage

if (isDev) {
    app.register(fastifyWebsocket);
    const fastifyRefresh = new FastifyRefresh(app);

    chokidar
        .watch(publicDir, { ignoreInitial: true })
        .on('all', (event, filePath) => {
            fastifyRefresh.refresh();
        });
}

"No configuration, no extra steps—just drop it in and it works."

FEATURES

  • Zero Config - Just use it, and it auto-injects everything for you.
  • Unopinionated - Trigger it manually or automate it with a file watcher.
  • Minimal - Lightweight, atomic, and dependency-free.

Installation

npm  install  fastify-refresh

License

Licensed under the Apache License 2.0.

Package Sidebar

Install

npm i fastify-refresh

Weekly Downloads

9

Version

1.0.0

License

Apache-2.0

Unpacked Size

26.1 kB

Total Files

6

Last publish

Collaborators

  • alexstevovich