Fetches and caches a single content item for inline chat card rendering by hitting the same list-API endpoints used by public pages (`/blog`, `/case-studies`, `/podcasts`, etc.), ensuring a consistent data shape with full relational joins. ## Key Components ### `UseChatCardItemResult` Return type interface exposing: - `item: T | undefined` — the resolved content item - `isLoading: boolean` — TanStack Query loading state - `isError: boolean` — TanStack Query error state ### `useChatCardItem(type, id)` Primary hook. Resolves the list URL via `runtime.endpoints.buildListUrl`, fetches through `embedAuthedFetch` (preserving auth credentials), extracts the matching item, and returns the typed result. **Key behaviors:** - **Deduplication** — queries are keyed by `['chat-card-item', type, id]`; multiple references to the same content in one chat message produce a single network request - **Auth-aware fetching** — uses `embedAuthedFetch` (not bare `fetch`) to traverse the `EmbedAuthAdapter` (cookie/Bearer/401-retry), preventing blank cards behind a gateway - **Streaming-safe caching** — `staleTime: 5min` / `gcTime: 30min` prevents skeleton flashes on every chunk as markdown re-parses during streaming assistant messages - **No focus refetching** — `refetchOnWindowFocus: false` avoids wasteful re-fetches when users toggle the chat panel ## Usage Example ```typescript import { useChatCardItem } from './use-chat-card-item' interface BlogPost { id: string title: string slug: string author: { name: string } } function ChatBlogCard({ id }: { id: string }) { const { item, isLoading, isError } = useChatCardItem('blog', id) if (isLoading) return if (isError || !item) return null return } ``` ## Dependencies | Dependency | Role | |---|---| | `@tanstack/react-query` | Query lifecycle, deduplication, caching | | `useRequiredChatRuntime` | Provides `buildListUrl` per content type | | `embedAuthedFetch` | Auth-aware fetch (cookie / Bearer / retry) | | `extractItems` / `extractItemId` | Normalizes list-API response envelope | **Source:** [`src/.../use-chat-card-item.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/hooks/use-chat-card-item.ts)