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

@qq1766141548/web-version-refresh

v0.1.0

Published

Framework-independent browser resource version refresh with Vite integration.

Readme

@qq1766141548/web-version-refresh

Framework-independent browser resource version checking with a Vite build plugin.

Install

npm install @qq1766141548/web-version-refresh

Configure Vite

import { defineConfig } from 'vite'
import { webVersionPlugin } from '@qq1766141548/web-version-refresh/vite'

export default defineConfig({
  plugins: [
    webVersionPlugin({
      version: process.env.BUILD_VERSION || '1.0.0',
    }),
  ],
})

The plugin injects the build version into the generated HTML and JavaScript bundle, emits app-version.json, and serves the manifest during Vite development.

For production builds, the plugin also injects a small script before other resources. It immediately checks the deployed version and listens for entry script, stylesheet, module preload, and Vite dynamic chunk failures. A stale page or failed asset load is retried once with ?__app_version__=<version>, without depending on the application bundle being able to start.

CI/CD

Pass a stable, unique application version into the Vite build. A Git commit SHA, release number, or CI pipeline ID is recommended:

BUILD_VERSION="$CI_COMMIT_SHA" npm run build

GitHub Actions example:

- name: Build web application
  run: npm run build
  env:
    BUILD_VERSION: ${{ github.sha }}

The value is read by the Vite configuration shown above. During the same build, the plugin injects that value into the generated HTML and JavaScript bundle and writes it to dist/app-version.json, so no separate manifest-generation command is required.

Deploy the complete output directory from that build as one release. Do not reuse an app-version.json from another build or change it after the bundle has been built. When a platform cannot deploy atomically, upload hashed static assets first and publish the HTML and app-version.json only after those assets are available.

BUILD_VERSION identifies the deployed web application, not the npm package version of @qq1766141548/web-version-refresh. Keep it unchanged when retrying deployment of the same artifact, and change it whenever a new frontend artifact is released.

Vite Application Usage

No application entry-point call is required. Registering webVersionPlugin() is sufficient because the generated HTML performs the asynchronous check.

The HTML check can be configured or disabled:

webVersionPlugin({
  version: process.env.BUILD_VERSION || '1.0.0',
  htmlCheck: {
    requestTimeout: 3000,
    versionQueryKey: '__app_version__',
  },
})

Use manifestUrl when the version is returned by a backend endpoint or hosted outside the Vite base path:

webVersionPlugin({
  version: process.env.BUILD_VERSION || '1.0.0',
  manifestUrl: '/api/web/version',
})

The endpoint must return a top-level, non-empty version:

{
  "version": "20260813-a1b2c3d"
}

For a relative Vite base, the generated relative manifest path is resolved from the current document URL. Override manifestUrl when history-mode routing and the deployment layout require a fixed manifest location.

The injected script is inline. A strict Content Security Policy must allow it through an appropriate nonce or hash. Set htmlCheck: false when the deployment cannot allow inline scripts; in that mode, use the runtime API after the application starts.

Manual Runtime API

checkWebVersion() remains available for non-Vite integrations or builds with htmlCheck: false:

import { checkWebVersion } from '@qq1766141548/web-version-refresh'

void checkWebVersion()

Avoid calling the runtime API again during initial startup when the default HTML check is enabled; that would duplicate the same request. It remains useful at later business nodes such as route changes, visibility restoration, or before a critical workflow.

Set autoRefresh: false to show an application prompt before refreshing:

const result = await checkWebVersion({ autoRefresh: false })

if (result.status === 'outdated') {
  const confirmed = window.confirm('A new version is available. Refresh now?')
  if (confirmed) result.refresh()
}

The result status is current, outdated, refreshing, or error. An outdated result provides refresh(), which reloads the current route with the target version while preserving its other query parameters and hash. The package does not depend on Vue, React, or another UI framework.