This repository contains the source code for Sentinel, a lightweight update manager for React/Vite applications. It detects when a new version of your app is deployed and handles updates gracefully—either by showing a "New version available" banner or by silently reloading on the next navigation.
This monorepo is managed with npm workspaces and includes the following packages:
| Package | Description |
|---|---|
@sentinel-js/react |
React SDK: useSentinel hook and <SentinelToast /> component for polling and update UI. |
@sentinel-js/vite-plugin |
Vite plugin that generates a unique build hash and injects it into the app, and writes version.json to the build output. |
The React SDK depends on the Vite plugin at build time: the plugin injects __SENTINEL_VERSION__ and writes version.json; the SDK polls that file and compares versions to detect updates.
- Node.js v18 or later
- npm (v7+ for workspaces) or pnpm
-
Clone and install dependencies:
git clone <repository-url> cd sentinel-monorepo npm install
-
Build all packages:
npm run build
This runs
npm run buildin each workspace (packages/react,packages/vite-plugin). -
Run the playground (recommended for local testing):
The
playgroundapp uses the local packages and the Sentinel plugin. Use it to verify changes end-to-end.cd playground npm run devThen open the URL shown (e.g.
http://localhost:5173). To test the production build and update detection:cd playground npm run build npm run preview
| Script | Description |
|---|---|
npm run build |
Build all workspace packages. |
npm run publish |
Publish all workspace packages (use with Changesets workflow). |
packages/react:npm run build(tsc + vite build),npm run dev(vite build --watch)packages/vite-plugin:npm run build(tsup),npm run dev(tsup --watch)
This repo uses Changesets for versioning and publishing.
-
Create a changeset (describe your change and choose which packages to bump):
npx changeset
-
Version packages (apply changesets and update
CHANGELOGs):npx changeset version
-
Publish to npm (only run when ready to release):
npx changeset publish
sentinel-monorepo/
├── packages/
│ ├── react/ # @sentinel-js/react
│ │ ├── src/
│ │ ├── dist/ # built output (gitignored)
│ │ └── package.json
│ └── vite-plugin/ # @sentinel-js/vite-plugin
│ ├── src/
│ ├── dist/ # built output (gitignored)
│ └── package.json
├── playground/ # Demo app (Vite + React) using both packages
├── .changeset/ # Changeset config and pending changesets
├── package.json # Workspace root
└── README.md
MIT
See TROUBLESHOOTING.md for common issues and solutions, including:
- React hook errors in development mode
- Version showing as "unknown"
- Update detection not working
- Build errors with Vite 6/7