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

vite-plugin-vue-updater

v1.0.0

Published

Vue 3 + Vite auto-update solution with Element Plus integration

Readme

✨ 特性

  • ⚡️ 零配置:开箱即用,自动生成版本标识。
  • 🔄 智能轮询:基于 visibilityState 的高性能轮询机制,支持时间戳防缓存。
  • 🛡️ 交互闭环:内置“强提醒(Modal) -> 拒绝 -> 弱提醒(Notification)”的最佳实践策略。
  • 🎨 UI 集成:深度集成 Element Plus,支持文案与行为自定义。
  • 🔧 TS 支持:完全使用 TypeScript 编写,提供完整的类型推断。

📦 安装

# pnpm
pnpm add vite-plugin-vue-updater

# npm
npm install vite-plugin-vue-updater

# yarn
yarn add vite-plugin-vue-updater

⚠️ 注意:本项目依赖 element-plus、vue 和 axios,请确保你的项目中已安装它们。

🚀 快速开始

  1. 配置 Vite 插件 在 vite.config.ts 中引入插件,用于构建时生成 version.json。
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { versionUpdatePlugin } from 'vite-plugin-vue-updater'

export default defineConfig({
  plugins: [
    vue(),
    // 在构建时自动生成 dist/version.json
    versionUpdatePlugin()
  ]
})
  1. 在 App.vue 中启用 在你的根组件中引入 Hook,即可开启自动检测。
<script setup lang="ts">
import { onMounted, onUnmounted } from 'vue'
import { useVersionCheck } from 'vite-plugin-vue-updater'

const isProd = import.meta.env.PROD
let updater: any

onMounted(() => {
  if (isProd) {
    updater = useVersionCheck({
      // 轮询间隔(毫秒),默认 60000
      timer: 5 * 60 * 1000,
      // version.json 的地址,注意处理 base 路径
      jsonUrl: `${import.meta.env.BASE_URL}version.json`,
      // 自定义 UI 文案
      ui: {
        title: '系统升级',
        description: '检测到新版本,请刷新页面以加载最新功能。',
        confirmText: '立即刷新',
        cancelText: '稍后再说'
      }
    })
  }
})

onUnmounted(() => {
  updater?.destroy()
})
</script>

📚 详细文档 请访问 官方文档 查看完整的配置项和高级用法。

📄 License MIT.