Skip to main content
The comments module provides full server-side control over comments on entities. Use it to seed content, build moderation pipelines, or integrate comment data into your backend logic.

createComment

Creates a new comment on an entity.
const comment = await replyke.comments.createComment({
  entityId: "ent_xyz789",
  userId: "usr_abc123",
  content: "Great post!",
});
entityId
string
required
The Replyke entity ID to comment on.
userId
string
required
The Replyke user ID of the comment author.
content
string
required
The comment text content.
foreignId
string
Your application’s identifier for this comment.
parentId
string
The Replyke comment ID of the parent, for creating a reply.
referencedCommentId
string
A comment being directly quoted or referenced.
attachments
array
File or media attachments on the comment.
metadata
object
Arbitrary metadata attached to the comment.
createdAt
string
ISO 8601 timestamp to backdate the comment’s creation time.
updatedAt
string
ISO 8601 timestamp to backdate the comment’s last update time.
ReturnsPromise<Comment>

fetchComment

Fetches a single comment by its Replyke ID.
const comment = await replyke.comments.fetchComment({ commentId: "cmt_abc123" });
commentId
string
required
The Replyke comment ID.
ReturnsPromise<Comment>

fetchCommentByForeignId

Fetches a comment by your application’s own identifier.
const comment = await replyke.comments.fetchCommentByForeignId({
  foreignId: "my-comment-id-99",
});
foreignId
string
required
Your application’s comment identifier.
ReturnsPromise<Comment>

updateComment

Updates the content or timestamp of an existing comment.
const comment = await replyke.comments.updateComment({
  commentId: "cmt_abc123",
  content: "Edited comment text",
});
commentId
string
required
The Replyke comment ID to update.
content
string
required
The new comment text.
createdAt
string
Override the creation timestamp (ISO 8601). Useful for data migrations.
ReturnsPromise<Comment>

deleteComment

Permanently deletes a comment.
await replyke.comments.deleteComment({ commentId: "cmt_abc123" });
commentId
string
required
The Replyke comment ID to delete.
ReturnsPromise<void>

fetchManyComments

Fetches a paginated list of comments on an entity. Supports top-level and reply-level fetching.
const { data, metadata } = await replyke.comments.fetchManyComments({
  entityId: "ent_xyz789",
  sort: "top",
  page: 1,
  limit: 20,
});
entityId
string
required
The Replyke entity ID to fetch comments for.
parentId
string
When provided, fetches replies to this specific comment ID instead of top-level comments.
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
sort
string
Sort order: "top" (highest scored), "new" (most recent first), or "old" (oldest first).
ReturnsPromise<PaginatedResponse<Comment>>

addReaction

Adds a reaction from a user to a comment.
const reaction = await replyke.comments.addReaction({
  commentId: "cmt_abc123",
  userId: "usr_abc123",
  reactionType: "like",
});
commentId
string
required
The Replyke comment ID.
userId
string
required
The Replyke user ID of the reactor.
reactionType
ReactionType
required
One of: "upvote", "downvote", "like", "love", "wow", "sad", "angry", "funny".
ReturnsPromise<Reaction>

removeReaction

Removes a user’s existing reaction from a comment.
await replyke.comments.removeReaction({
  commentId: "cmt_abc123",
  userId: "usr_abc123",
});
commentId
string
required
The Replyke comment ID.
userId
string
required
The Replyke user ID whose reaction to remove.
ReturnsPromise<void>

fetchReactions

Fetches a paginated list of reactions on a comment, optionally filtered by reaction type.
const { data, metadata } = await replyke.comments.fetchReactions({
  commentId: "cmt_abc123",
  reaction: "upvote",
  page: 1,
  limit: 20,
});
commentId
string
required
The Replyke comment ID.
reaction
ReactionType
Filter to a specific reaction type.
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<Reaction>>

getUserReaction

Checks what reaction (if any) a specific user has left on a comment.
const { reactionType } = await replyke.comments.getUserReaction({
  commentId: "cmt_abc123",
  userId: "usr_abc123",
});
// reactionType is "like" | "upvote" | ... | null
commentId
string
required
The Replyke comment ID.
userId
string
required
The Replyke user ID to check.
ReturnsPromise<{ reactionType: ReactionType | null }>