# useKivaAgentMemories URL: /docs/native/hooks/use-kiva-agent-memories Backend glue for the KivaAgent memory manager — list, create, update and delete /v1/ai/memories with optimistic local state. ## Installation ```bash pnpm dlx @kivacore/ui-cli add @kivacore/rn-hooks-use-kiva-agent-memories ``` A verbatim port of the web hook (no React Query — plain local state with optimistic updates). Feed its result into [`KivaAgentMemoriesView`](/docs/native/kiva/kiva-agent#memories). ## Usage ```tsx import { KivaAgentMemoriesView } from '@/components/kiva-native/kiva-agent'; import { useKivaAgentMemories } from '@/hooks/kiva-native/use-kiva-agent-memories'; const memories = useKivaAgentMemories({ client, agentId: AGENT_ID, userId: user?.id }); ``` ## API Reference ### UseKivaAgentMemoriesArgs | Option | Type | Default | Description | |--------|------|---------|-------------| | `client` | `KivaAgentMemoriesClient \| null \| undefined` | - | Client with `get` / `post` / `patch` / `delete` | | `enabled` | `boolean` | `true` | Run the initial fetch | | `agentId` | `string` | - | Agent scope of created memories | | `projectId` | `string \| null` | `null` | Project scope of created memories | | `userId` | `string \| null` | `null` | User scope of created memories | | `listParams` | `Record` | - | Extra query params for the list call | ### UseKivaAgentMemoriesResult | Field | Type | Description | |-------|------|-------------| | `memories` | `ReadonlyArray` | Current list | | `isLoading` / `isSaving` | `boolean` | Fetch / save state | | `deletingId` | `string \| null` | Memory being deleted | | `error` | `string \| null` | Last error message | | `refresh` | `() => Promise` | Re-fetch `GET /v1/ai/memories` | | `create` | `(form: KivaAgentMemoryFormState) => Promise` | `POST /v1/ai/memories` | | `update` | `(memory, form) => Promise` | `PATCH /v1/ai/memories/{id}` | | `remove` | `(memory) => Promise` | `DELETE /v1/ai/memories/{id}` |