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

cf-comment

v0.2.0

Published

React comment client for static sites, built on Cloudflare Workers.

Readme

cf-comment

React 评论客户端 · 为静态站点(博客 / 文档)直接嵌入

基于 Cloudflare Workers + D1 后端。零额外运行时依赖(React 为 peer)。

安装

pnpm add cf-comment react react-dom

快速开始

import { Comment } from 'cf-comment'
import 'cf-comment/styles.css'

export function BlogComments() {
  return (
    <Comment
      serverURL="https://api.example.com"
      path="/posts/hello"
      lang="zh-CN"
      darkMode="auto"
    />
  )
}

登录 / 匿名发言

  • 登录:右上角登录或注册(Cookie usid),表单只填内容即可发表
  • 匿名:填写昵称 + 邮箱后发表
  • 跨域需 Worker ALLOWED_ORIGINS 包含站点 Origin,且请求 credentials: 'include'

Props

| 选项 | 类型 | 默认 | 说明 | |------|------|------|------| | serverURL | string | — | 服务端域名(必填),内部拼接 /v1/comment | | path | string | location.pathname | 页面标识 | | lang | 'zh-CN' \| 'en' | 'zh-CN' | 界面语言 | | darkMode | 'auto' \| 'light' \| 'dark' | 'auto' | 暗色模式 | | maxNesting | number | 6 | 最大嵌套层级 | | showCount | boolean | true | 是否显示评论计数 | | pageSize | number | 20 | 每页条数(上限 50) | | sort | 'desc' \| 'asc' | 'desc' | 排序 | | className | string | — | 容器 class | | onCommentPosted | (comment) => void | — | 发表成功回调 | | onCommentsLoaded | (tree) => void | — | 列表加载回调 | | onError | (error) => void | — | 错误回调 |

进阶:只用 API

API 客户端随主包导出(不再单独发布 core 子路径):

import { CommentClient, CfCommentError, buildTree } from 'cf-comment'

const client = new CommentClient('https://api.example.com')
const { tree, total } = await client.list('/posts/hello')

也导出 useComments hook,便于自建 UI。

样式

.cfc-container {
  --cfc-accent: #4f46e5;   /* 主题色 */
  --cfc-radius: 12px;
  --cfc-radius-lg: 16px;
  --cfc-avatar-size: 40px;
  --cfc-font-size: 15px;
}

暗色:darkMode="auto" | "light" | "dark"。

本地开发

# 根目录:先起 Worker
pnpm dev

# 另开终端:起 client demo
pnpm dev:client
# → http://localhost:5173

构建

pnpm build:client

License

MIT