Provides a React hook that resolves relative links inside doc bodies by POSTing to a configurable endpoint, returning a `ResolveLinkResult` envelope with graceful error handling. ## Key Components ### `useDocsResolveLink(sourceId, resolveLinkEndpoint?)` A memoized callback hook that resolves relative hrefs found in doc content to their full navigable targets. **Parameters:** - `sourceId` — identifies the doc source sent in the request body - `resolveLinkEndpoint` *(optional)* — per-instance endpoint override; falls back to `ChatRuntime.endpoints.docsResolveLinkUrl`, then `'/api/docs/resolve-link'` **Endpoint resolution chain:** ```text resolveLinkEndpoint prop ?? ChatRuntimeProvider endpoints.docsResolveLinkUrl ?? '/api/docs/resolve-link' ``` **Returned callback signature:** ```typescript (href: string, currentPath: string) => Promise ``` Returns `{ success: false, error }` on HTTP errors or network failures (DNS, CORS, offline), so callers never receive an unhandled rejection. ## Usage Example ```typescript import { useDocsResolveLink } from './use-docs-resolve-link' function DocLinkRenderer({ sourceId }: { sourceId: string }) { const resolveLink = useDocsResolveLink(sourceId) const handleLinkClick = async (href: string, currentPath: string) => { const result = await resolveLink(href, currentPath) if (!result.success) { console.warn('Link resolution failed:', result.error) return // render broken-link badge } // navigate to result.url or open preview } } ``` With a custom endpoint override (per-instance configuration): ```typescript const resolveLink = useDocsResolveLink(sourceId, '/api/custom/resolve-link') ``` ## Notes - Re-memoized only when `sourceId` or the resolved endpoint changes (`useCallback` deps) - Non-JSON and non-`ok` responses are normalized to `{ success: false, error }` — no uncaught rejections reach the markdown renderer's click handler - Source: [`use-docs-resolve-link.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/use-docs-resolve-link.ts)