Ship a Full Comment Section in Your React App Today

A Drop-In Comments Component With Reactions and Ratings

Skip building comments from scratch. Install the Hyvor Talk React library, render one component, and your app has real-time comments, replies, notifications, and moderation.

Installation guide About 5 minutes

Steps to Add Comments to React

The Hyvor Talk React library wraps our embeds as React components. You'll need a website ID: sign up at the Hyvor Talk Console, add your website with your app's domain, and copy the ID from Settings → Website.

  1. Install the library:

    npm install @hyvor/hyvor-talk-react
  2. Render the <Comments> component where you want the comments, for example at the end of a post. Its props are the same as the embed attributes.

    import { Comments } from "@hyvor/hyvor-talk-react";
    
    export default function Post({ post }) {
        return (
            <article>
                <h1>{post.title}</h1>
                <div>{post.content}</div>
    
                <Comments website-id={YOUR_WEBSITE_ID} page-id={post.id} />
            </article>
        );
    }

    Replace YOUR_WEBSITE_ID with your website ID, and use an ID that never changes for page-id, like the post's database ID.

Show comment counts

Use <CommentCount> to show how many comments each post has, for example in a post list. Add the components, then call CommentCounts.load() once they're mounted.

import { useEffect } from "react";
import { CommentCount } from "@hyvor/hyvor-talk-react";
import { CommentCounts } from "@hyvor/hyvor-talk-base";

export default function PostList({ posts }) {
    useEffect(() => {
        CommentCounts.load({
            "website-id": YOUR_WEBSITE_ID,
        });
    }, []);

    return posts.map((post) => (
        <a key={post.id} href={post.url}>
            {post.title} (<CommentCount page-id={post.id} />)
        </a>
    ));
}

Listen to events

Pass handlers in the on prop to run your own code on events. To call the API methods, use a ref, which gives you the underlying web component.

<Comments
    website-id={YOUR_WEBSITE_ID}
    page-id={post.id}
    on={{
        loaded: () => console.log("Comments loaded"),
        "comment:published": (comment) => console.log("New comment", comment),
    }}
/>

That's it. Run your app and the comment section loads where you placed it. The React library README has more examples.

Frequently asked questions

Install @hyvor/hyvor-talk-react and render the <Comments> component with your website ID and a page ID. That one component gives you the whole comment section, with no backend or database to build.

A component library. You import <Comments> like any other React component and pass props. Under the hood, it wraps the <hyvor-talk-comments> web component, so every embed attribute works as a prop.

Comments look simple until you need replies, notifications, spam filtering, moderation, and logins. A commenting platform for React handles all of that, so you spend your time on your app. You still control the look from the Console or with custom CSS.

Something that never changes for that page, like a post ID from your database. If you leave it out, the canonical URL is used, which breaks threads when URLs change. See page-id.

Yes. Pass an on prop with handlers for events like loaded or comment:published. You can also use a ref to reach the web component and call its API.

Yes, with single sign-on. Pass the SSO attributes as props and users comment with the account they already have. SSO is part of the Business plan.

Yes. The same <Comments> component shows reactions or star ratings above the comments, so there is nothing else to add. See audience engagement.

Start the 14-day free trial, no credit card required. Plans are on the pricing page.

Start your 14-day free trial now!

14-day free trial
No credit card required
Cancel anytime