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

react-comments-module

v0.0.20

Published

Lean react comments module

Readme

react-comments-module

A simple Comments implementation for articles, blogs, forums. This code is provided as plug and play to allow you to inject a Comments section in your app.

  • Facebook and Google login
  • Reply to comments
  • Light on dependencies
  • Comments managed by consummer or provide an endpoint for the app to CRUD comments
  • Plug and play

Demo: react comments module

Run it locally to see what it can do

npm install && npm run dev

Use it (https://www.npmjs.com/package/react-comments-module)

npm install react-comments-module

Example

import React from 'react';
import { ReactComment } from 'react-comments-module';
...

<ReactComment
  configuration={
    {
     apiUrl: "/articles/12345/comments"
     showCount: true,
     facebookClientId: "12345678910111213",
     googleClientId: "12345678910111213-ghvhbdskjbsadjabsd.apps.googleusercontent.com",
     writeCommentPrompt: "Write a comment using :  ",
     allowEdit: true,
     allowDelete: true,
     allowReply: true
    }
  }
/>

When using apiUrl

  • GET, POST, PATCH, DELETE will be executed against apiUrl like:
  • GET /articles/12345/comments will get you all comments
  • POST /articles/12345/comments will add a new comment
  • DELETE /articles/12345/comments/23 will remove comment with id 23

If apiUrl doesn't do it for you

Pass a CommentStore to ReactComment.configuration

function CommentStore() {
    return {
        all:    () => {},
        add:    (payload) => {},
        remove: (id) => {},
        edit:   (id, payload) => {}
    }
}

<ReactComment
  configuration={
    {
      commentStore: commentStore
    }
  }
/>

Rendering

We use Material UI (mui) to help us out with our post rendering (see demo), but if you hate google you can extend Model and override painter() to use your own magic.

import { Model } from 'react-comments-module';
class MagicModel extends Model {
  painter(props) {
    const { name, picture, id, comment, createdAt, userId } = this.attributes;
    return (
      <div>
        {comment}
      </div>
    )
  }
}

<ReactComment
  configuration={
    {
      CommentModel: MagicModel
    }
  }
/>

See the Model to find out what attributes we expect to see when CRUDing. You can modify, map, or override the Model as your backend requires

Events

We include some postEvents for those actions that are directly related to comments updates

<ReactComment
  onCommentAdded={commentAdded}
  onCommentUpdated={commentUpdated}
  onCommentRemoved={commentRemoved} 
/>

Identity

We include an identity provider that presents itself as a convenient action to get Facebook and Googles userName and picture. We want to include an anonymous provider for those cases when a formal identity is not needed. (later) In case the IdentityProvider doesn't work for you, import the login button flows from 'social-login-react' and create your own identityProvider

import { FacebookSignIn, GoogleSignIn } from 'react-comments-module';
function IdentityResolver(props) {
  //onIdentityObtained will seed the current context with the identity passed
  return (
    <FacebookSignIn
      appId={facebookClientId}
      onSuccessLogin={(data) => {
        props.onIdentityObtained({ picture: data.picture.data.url, ...data})
    }}
  />
  )
}

<ReactComment
  configuration={
    {
      IdentityProvider: IdentityResolver
    }
  }
/>

TODO

We are using Facebooks lexical editor which is still in Beta. This package itself will remain in Beta (or early dev) until issues list marked as 'feature' are all resolved.

Issues list includes:

  • Add anonymous Signin
  • Allow customize Social Login buttons
  • Multiple levels of reply threading (forum style)
  • and more ...