Skip to content

Reactions

Introduction

Reactions are a way for users to express their feelings about a comment without having to write a full reply. However, Headless Comments also allows users to react to pages which can be useful for a variety of use cases.

Both comment and page reactions work in a similar way. When a visitor clicks an emoji, a reaction is created and associated with the comment or page. The reaction is then displayed alongside the comment or page, allowing other visitors to see it.

Internally, Headless Comments stores reactions as words, such as like, love, laugh, etc. This allows you to customize the emojis that are displayed to your users, while still keeping the data consistent.

Visitors and privacy

Each visitor can be seen as a unique IP address that’s hashed to protect their privacy. This means that you can see how many unique visitors have reacted to a comment or page, but you can’t see who they are.

A visitor can only react once to a comment or page with a specific emoji. If they try to react again with the same emoji, their previous reaction will be set to be removed.

To prevent abuse, Headless Comments also limits the number of reactions a visitor can create in a specific time frame.

Configuration

To toggle reactions on or off for a specific site, you can use the allow reactions setting in the Site Settings.

Available emojis

By default, Headless Comments supports the following emojis:

  • like
  • love
  • laugh
  • dislike
  • wow
  • sad
  • angry
  • upvote
  • downvote

Via the API

List reactions

You can also interact with reactions via the API. Here’s how you can get all reactions for a specific comment or page:

Request

GET /reactions/comments/:id
GET /reactions/pages?slug=/blog/hello-world

Available query parameters

  • reaction - The emoji to filter reactions by (optional)

Response

{
"like": 10,
"love": 5,
"laugh": 3
}

Create a reaction

Request

POST /reactions

Headers

X-Site-Id: 01j509cg4wwxtdtef3xws5kgf2
X-Slug: /blog/hello-world (for page reactions)
X-Comment-Id: 01j50c3ex8t6aw1ez40wys52j4 (for comment reactions)

Body

{
"reaction": "like"
}

Response

{
"message": "Reaction ingested successfully"
}