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

tiktok-comments

v0.3.0

Published

TikTok-style comment section UI for React and Next.js apps

Readme

tiktok-comments

TikTok-style comment section UI packaged as a React library with isolated Tailwind CSS (tcm: prefix) for safe use in host apps.

Install

npm install tiktok-comments

Usage (React SPA)

import { CommentSection, type CommentApiPayload } from "tiktok-comments";
import "tiktok-comments/styles.css";

function mapResponse(raw: unknown): CommentApiPayload {
  return raw as CommentApiPayload;
}

export function VideoComments() {
  return <CommentSection url="/api/comments" response={mapResponse} theme="dark" />;
}

Usage (Next.js App Router)

Import the CSS once in your root layout:

import "tiktok-comments/styles.css";

Use the component in a client page or client component:

"use client";

import { CommentSection, type CommentApiPayload } from "tiktok-comments";

export default function CommentsPage() {
  return <CommentSection url="/api/comments" response={(raw) => raw as CommentApiPayload} />;
}

API

CommentSection fetches from url. Map your API JSON with response.

| Prop | Type | Description | |------|------|-------------| | url | string | Comments resource, e.g. /api/comments | | response | (raw: unknown) => CommentApiPayload | Maps list and mutation JSON | | endpoints | Partial<CommentSectionEndpoints> | Per-route URL overrides; unset keys default from url (see below) | | theme | "dark" \| "light" | Default "dark" | | className | string | Extra classes on root | | showThemeToggle | boolean | Show theme toggle beside search. Default false | | onThemeChange | (theme: "dark" \| "light") => void | Called when user toggles theme (use with theme for controlled mode) | | onViewProfile | (profile: CommentProfile) => void | Optional host navigation for View profile (overrides profile.profileUrl) | | onReportSticker | (src: string) => void | Optional host handler when user reports a posted sticker |

endpoints defaults (all derived from url unless overridden):

| Key | Default | Method | |-----|---------|--------| | list | url | GET + q, sort, offset, limit | | submit | url | POST | | likeComment(id) | {url}/{id}/like | POST | | dislikeComment(id) | {url}/{id}/dislike | POST | | likeReply(commentId, replyId) | {url}/{commentId}/replies/{replyId}/like | POST | | dislikeReply(commentId, replyId) | {url}/{commentId}/replies/{replyId}/dislike | POST | | users | {url}/users | GET | | userByName(name) | {url}/users?name= | GET | | stickers | {url}/stickers | GET + query | | stickerFavorite(id) | {url}/stickers/{id}/favorite | POST |

<CommentSection
  url="/api/comments"
  response={mapResponse}
  endpoints={{
    users: "/api/authors",
    userByName: (name) => `/api/authors?name=${encodeURIComponent(name)}`,
    stickers: "/api/sticker-catalog",
  }}
/>

Exported helpers: defaultCommentSectionEndpoints, resolveCommentSectionEndpoints, types CommentSectionEndpoints, CommentSectionEndpointsConfig.

Exported types: Comment, Reply, Attachment, CommentUser, CommentProfile, EarnedBadge, SubscriptionTier, ReplyTarget, CommentSort, CommentApiPayload.

CSS isolation

All Tailwind utilities use the tcm: prefix (e.g. tcm:flex, tcm:hover:tcm:bg-muted). Theme tokens are scoped under .tcm-root, so host app CSS variables are not overwritten.

Development

npm install
npm run dev        # demo playground + in-memory mock API (`/api/comments`)
npm run check      # typecheck + lint
npm run build      # library + CSS to dist/

License

MIT