Skip to main content
Replyke supports 8 distinct reaction types on both entities and comments. Each reaction type has a defined impact on the author’s reputation score.

Reaction Types

TypeReputation Impact
upvote+1
downvote-1
like+1
love+2
wow+1
sad0
angry0
funny+1
Each entity and comment stores a reactionCounts object with a count for each type, and a userReaction field with the authenticated user’s current reaction (or null).

The Toggle Pattern

The recommended way to work with reactions is useReactionToggle. It manages optimistic updates, handles toggling (selecting the same reaction again removes it), and reverts state on server errors.
import { useReactionToggle } from "@replyke/react-js";

function ReactionButton({ entity }) {
  const { currentReaction, reactionCounts, toggleReaction, loading } = useReactionToggle({
    targetType: "entity",
    targetId: entity.id,
    initialReaction: entity.userReaction,
    initialReactionCounts: entity.reactionCounts,
  });

  return (
    <button
      onClick={() => toggleReaction({ reactionType: "upvote" })}
      disabled={loading}
    >
      {reactionCounts.upvote ?? 0} Upvotes
      {currentReaction === "upvote" ? " (active)" : ""}
    </button>
  );
}

Hooks

useReactionToggle

Manage reaction state with optimistic updates and toggle behavior. The recommended hook for reaction UIs.

useAddReaction

Low-level hook to add a reaction to an entity or comment.

useRemoveReaction

Low-level hook to remove the authenticated user’s reaction.

useFetchEntityReactions

Fetch a paginated list of reactions on an entity, optionally filtered by type.

useFetchCommentReactions

Fetch a paginated list of reactions on a comment, optionally filtered by type.