npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sentinel-js/vite-plugin

v0.1.5

Published

A Vite plugin that works with **`@sentinel-js/react`**. It generates a unique build hash, injects it into your app at build time, and writes a `version.json` file to your output directory so the React SDK can detect when a new version is deployed.

Downloads

596

Readme

@sentinel-js/vite-plugin

A Vite plugin that works with @sentinel-js/react. It generates a unique build hash, injects it into your app at build time, and writes a version.json file to your output directory so the React SDK can detect when a new version is deployed.

Installation

npm install @sentinel-js/vite-plugin -D
# or
pnpm add -D @sentinel-js/vite-plugin

Peer dependency: vite ^4.0.0, ^5.0.0, ^6.0.0, or ^7.0.0.

Setup

Add the plugin to your Vite config. No other configuration is required.

// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import sentinelPlugin from '@sentinel-js/vite-plugin';

export default defineConfig({
  plugins: [
    react(),
    sentinelPlugin({
      fileName: 'version.json',  // optional, default: 'version.json'
      log: true,                 // optional, default: true
    }),
  ],
});

The plugin automatically injects the following so @sentinel-js/react works without React hook errors:

  • resolve.dedupe — Ensures a single copy of react and react-dom is used. Your existing dedupe entries are preserved and merged.
  • optimizeDeps.include — Ensures @sentinel-js/react is pre-bundled with your app’s React in dev mode. Your existing include entries are preserved and merged.

Plugin options

| Option | Type | Default | Description | |--------|------|--------|-------------| | fileName | string | 'version.json' | Name of the version file written to the build output (e.g. dist/). | | log | boolean | true | If true, logs the generated file name and build hash to the console after the build. |

How it works

  1. Hash generation
    When the plugin is applied, it generates a unique 12-character hash (MD5 of timestamp + UUID). The same hash is used for both injection and the version file.

  2. Injection
    The plugin adds a Vite define so that the global __SENTINEL_VERSION__ is replaced in your client code with that hash string. The React SDK reads this to know the “current” build version.

  3. Version file
    After the bundle is written, the plugin writes a JSON file (e.g. dist/version.json) with the same version and a timestamp. The React SDK polls this URL (by default /version.json) to compare the server version with the client version.

Example version.json:

{
  "version": "a1b2c3d4e5f6",
  "timestamp": 1234567890123
}

Your server must serve this file from the built output (e.g. same origin as the app at /version.json) so the SDK can fetch it without CORS issues.

When the plugin runs

  • vite dev: The plugin runs and injects resolve.dedupe and optimizeDeps.include so the React SDK works in development. __SENTINEL_VERSION__ is set to a hash for the dev session. No version.json file is written (that only happens on build).
  • vite build: Full behavior: injects __SENTINEL_VERSION__, writes version.json to your output directory (e.g. dist/), and the same dedupe/optimizeDeps apply to the build.

Integration with @sentinel-js/react

  1. Install both packages: @sentinel-js/react (dependency) and @sentinel-js/vite-plugin (dev dependency).
  2. Add the plugin to vite.config.ts as above.
  3. Use useSentinel or <SentinelToast /> in your app; they will read __SENTINEL_VERSION__ and poll /version.json (or the path you set via versionFileUrl).
  4. Deploy your built app and version.json together; ensure the version file is served at the URL you pass as versionFileUrl (default /version.json).

License

ISC