Skip to main content

Overview

useIsEntitySaved provides a function to check whether a specific entity is saved in any collection owned by the current user. The function returns the full result — including the list of collections the entity is saved in — leaving state management to the caller.
Requires an authenticated user. Throws if called without a logged-in user, an entity ID, or a project ID.

Usage Example

import { useState } from "react";
import { useIsEntitySaved } from "@replyke/react-js";

function SaveStatus({ entityId }) {
  const { checkIfEntityIsSaved } = useIsEntitySaved();
  const [savedStatus, setSavedStatus] = useState(null);

  useEffect(() => {
    checkIfEntityIsSaved({ entityId }).then(setSavedStatus);
  }, [entityId]);

  if (savedStatus === null) return <p>Checking...</p>;
  return <p>{savedStatus.saved ? "Saved" : "Not saved"}</p>;
}

Returns

checkIfEntityIsSaved
({ entityId }: { entityId: string }) => Promise<{ saved: boolean; collections: Array<{ id: string; name: string }> }>
Calls the API to determine whether the entity is saved in any of the user’s collections. Returns the full result including the list of collections the entity belongs to.
To also check membership in a specific collection, use isEntitySaved from useCollections — it accepts an optional collectionId and returns inSpecificCollection in addition to the full data.