Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.replyke.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

useEntity reads from the nearest EntityProvider in the component tree and returns the entity’s state and actions. It does not fetch data itself — it accesses what EntityProvider has already loaded.
useEntity must be used inside an EntityProvider. See EntityProvider & useEntity for setup instructions.

Usage Example

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

function EntityContent() {
  const { entity, updateEntity, deleteEntity } = useEntity();

  if (!entity) return <p>Loading...</p>;

  return (
    <div>
      <h1>{entity.title}</h1>
      <p>Views: {entity.views}</p>
    </div>
  );
}

Return Values

entity
Entity | null | undefined
The current entity. undefined while loading, null if not found.
setEntity
React.Dispatch
Direct state setter for the entity. Use for manual local state overrides.
updateEntity
(props: { update }) => Promise<Entity | undefined>
Updates the entity on the server and syncs local state. Accepts title, content, attachments, keywords, location, metadata, and mentions.
deleteEntity
() => Promise<void>
Deletes the entity and sets local state to undefined.