> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Reactions

> Query, add, and remove reactions on posts, comments, stories, and messages with the Social+ SDKs.

Reactions let signed-in users attach a named reaction such as `like` to content. The SDKs expose the same core shape on every platform: choose a reference type, pass the content ID, and pass the reaction name.

## Platform Surface

| Platform   | Query reactions                                            | Add reaction                            | Remove reaction                            |
| ---------- | ---------------------------------------------------------- | --------------------------------------- | ------------------------------------------ |
| TypeScript | `ReactionRepository.getReactions()`                        | `ReactionRepository.addReaction()`      | `ReactionRepository.removeReaction()`      |
| iOS        | `AmityReactionRepository.getReactions()`                   | `AmityReactionRepository.addReaction()` | `AmityReactionRepository.removeReaction()` |
| Android    | `AmityCoreClient.newReactionRepository().getReactions()`   | `addReaction()`                         | `removeReaction()`                         |
| Flutter    | `AmitySocialClient.newReactionRepository().getReactions()` | `addReaction()`                         | `removeReaction()`                         |

## Parameters

| Parameter                             | Required                               | Description                                                                            |
| ------------------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------- |
| `referenceType`                       | Yes                                    | Content type being reacted to. Supported values are post, comment, story, and message. |
| `referenceId`                         | Yes                                    | ID of the post, comment, story, or message.                                            |
| `reactionName`                        | Yes for add/remove, optional for query | Reaction key such as `like`. Query APIs can use it as a filter.                        |
| `callback` / live collection observer | Query only                             | Used by live collection APIs to receive reaction updates.                              |

## Query Reactions

Use `reactionName` when the UI only needs one reaction type. Omit it to read all reaction types for the content.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ReactionRepository } from "@amityco/ts-sdk";

  const unsubscribe = ReactionRepository.getReactions(
    {
      referenceType: "post",
      referenceId: postId,
      reactionName: "like",
    },
    ({ data }) => {
      renderResults(data);
    }
  );
  ```

  ```swift iOS theme={null}
  let reactionRepository = AmityReactionRepository()
  let reactions = reactionRepository.getReactions(
      postId,
      referenceType: .post,
      reactionName: "like"
  )

  token = reactions.observe { collection, error in
      guard error == nil else { return }
      let currentReactions = collection.snapshots
      showSuccessMessage(currentReactions.count)
  }
  ```

  ```kotlin Android theme={null}
  import com.amity.socialcloud.sdk.model.core.reaction.AmityReactionReferenceType

  AmityCoreClient.newReactionRepository()
      .getReactions(
          referenceType = AmityReactionReferenceType.POST,
          referenceId = postId,
          reactionName = "like"
      )
      .subscribe(
          { reactions -> showSuccessMessage(reactions) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  final reactions = AmitySocialClient.newReactionRepository()
      .getReactions(AmityPostReactionReference(referenceId: postId))
      .reactionName('like')
      .getLiveCollection();
  ```
</CodeGroup>

## Add And Remove Reactions

Adding or removing a reaction returns completion or success from the SDK call. Keep UI counts synced from the content model or the reaction live collection.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ReactionRepository } from "@amityco/ts-sdk";

  await ReactionRepository.addReaction("post", postId, "like");
  await ReactionRepository.removeReaction("post", postId, "like");
  ```

  ```swift iOS theme={null}
  let reactionRepository = AmityReactionRepository()

  try await reactionRepository.addReaction(
      "like",
      referenceId: postId,
      referenceType: .post
  )

  try await reactionRepository.removeReaction(
      "like",
      referenceId: postId,
      referenceType: .post
  )
  ```

  ```kotlin Android theme={null}
  import com.amity.socialcloud.sdk.model.core.reaction.AmityReactionReferenceType

  val reactionRepository = AmityCoreClient.newReactionRepository()

  reactionRepository.addReaction(
      referenceType = AmityReactionReferenceType.POST,
      referenceId = postId,
      reactionName = "like"
  )
      .subscribe(
          { showSuccessMessage("Reaction added") },
          { error -> handleGeneralError(error) }
      )

  reactionRepository.removeReaction(
      referenceType = AmityReactionReferenceType.POST,
      referenceId = postId,
      reactionName = "like"
  )
      .subscribe(
          { showSuccessMessage("Reaction removed") },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  final reactionRepository = AmitySocialClient.newReactionRepository();
  final reference = AmityPostReactionReference(referenceId: postId);

  await reactionRepository.addReaction(reference, 'like');
  await reactionRepository.removeReaction(reference, 'like');
  ```
</CodeGroup>

## Notes

* TypeScript accepts `post`, `comment`, `story`, and `message` as reaction reference types.
* iOS, Android, and Flutter expose equivalent enum or reference classes for post, comment, story, and message.
* Message reactions use the message reaction path in the SDKs. Do not use post or comment reference types for messages.
* Reaction names are application-defined strings. Use the same values when adding, removing, and filtering.

## Related Topics

<CardGroup cols={3}>
  <Card title="Comments" icon="message-square" href="/social-plus-sdk/social/content-management/comments/overview">
    React to comments and keep comment threads interactive
  </Card>

  <Card title="Stories" icon="images" href="/social-plus-sdk/social/content-management/stories/overview">
    Use the same reaction concept with story content
  </Card>

  <Card title="Messages" icon="message-circle" href="/social-plus-sdk/chat/messaging-features/messages/get-and-view-a-message">
    Add and remove reactions on chat messages
  </Card>
</CardGroup>
