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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vercount-react

v0.1.4

Published

The React component for Vercount, a simple website counter powered by NextJS.

Readme

vercount react banner@3x

vercount-react

vercount-react 是为 Vercount 设计的 React Hook,它提供了一个简单且高效的方式来统计网站流量。Vercount 是基于 Next.js 和 Redis 的快速网站计数器,适合那些需要可靠、快速、安全的流量统计方案的网站。

如果你更喜欢使用纯 JavaScript,请查看 vercount 仓库。

为什么选择 Vercount?

很多网站计数器,像不蒜子,速度慢且不够稳定,而 Vercount 提供了一种更好的选择:

  • 极速:服务器响应时间通常低于 10 毫秒。
  • 高可用性:针对中国优化的版本或者使用 Vercel 全球 CDN,确保 99.99% 的正常运行时间。
  • 精准统计:使用 POST 请求提高计数准确性,避免传统基于 Referrer 的方法带来的不准确性。
  • 安全性:通过 JSON 回调防止 CSRF 攻击,取代了不太安全的 JSONP 方式。
  • 自动同步:与 Busuanzi 的数据同步,无需手动操作。
  • 兼容性强:可以直接兼容现有的 Busuanzi 标签,轻松迁移。

安装

你可以用任意你喜欢的包管理器来安装 vercount-react

# 使用 npm
npm install vercount-react

# 使用 pnpm
pnpm install vercount-react

# 使用 yarn
yarn add vercount-react

使用方法

要在 React 项目中使用 Vercount 统计你的网站流量,只需导入 useVercount Hook,并在你的组件中调用它。

示例:

import { useVercount } from 'vercount-react'

export default function Home() {
  const { sitePv, pagePv, siteUv } = useVercount()

  return (
    <div>
      <h1>全站页面浏览量:{sitePv}</h1>
      <h2>当前页面浏览量:{pagePv}</h2>
      <h2>独立访客:{siteUv}</h2>
    </div>
  )
}

在这个例子中:

  • sitePv:整个网站的总页面浏览量。
  • pagePv:当前页面的浏览量。
  • siteUv:网站的独立访客数。

文档

useVercount Hook

useVercountvercount-react 的核心 Hook,它从 Vercount 后端获取网站和页面的流量统计信息。

const { sitePv, pagePv, siteUv } = useVercount()

返回值:

  • sitePv:全站页面浏览量。
  • pagePv:当前页面浏览量。
  • siteUv:全站独立访客数。

支持项目

Vercount 是一个开源社区驱动的项目。你的支持对于维持和发展项目至关重要。如果你愿意,请访问我的 捐赠页面,为项目提供帮助,或查看我的其他开发项目。


更多详细信息,请访问 Vercount 官方网站

免责声明

版权所有,EvanNotFound。