Skip to main content

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

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.