Resolves `target` and `rel` anchor attributes for entity cards by delegating the same-tab vs. new-tab decision to the `ChatRuntime` navigation callback, eliminating the need for hub-side wrapper components.
## Key Components
### `useEntityCardLink(args): EntityCardLinkProps`
Primary hook that computes anchor link attributes using a two-priority resolution strategy:
1. **Explicit override** — If `target` or `rel` props are passed directly, they win immediately. A missing `rel` is auto-paired with `'noopener noreferrer'` when `target='_blank'` to prevent tabnabbing.
2. **Runtime decision** — Falls back to `computeIsNewTab(runtime, href, targetPlatform)`, which mirrors the click handler in `executeNavigation`, keeping the rendered anchor and the click behavior in sync. Returns `{ target: undefined, rel: undefined }` (same-tab) when no runtime is mounted.
### Interfaces
| Interface | Purpose |
|---|---|
| `UseEntityCardLinkArgs` | Input: `href`, optional `targetPlatform`, optional explicit `target`/`rel` overrides |
| `EntityCardLinkProps` | Output: resolved `target` and `rel` values for spreading onto an anchor element |
## Usage Example
```typescript
import { useEntityCardLink } from './use-entity-card-link'
function BlogCard({ href, targetPlatform }: Props) {
const { target, rel } = useEntityCardLink({ href, targetPlatform })
return (
Read Post
)
}
// Explicit override — runtime decision skipped entirely
function ExternalCard({ href }: Props) {
const { target, rel } = useEntityCardLink({
href,
target: '_blank',
// rel auto-paired to 'noopener noreferrer'
})
return Open
}
```
## Notes
- Requires `HubRuntimeProvider` (or a compatible embed shim) to be mounted for runtime-derived decisions.
- Result is memoized on `[target, rel, href, targetPlatform, runtime]` — safe to call in render.
- Source: [`use-entity-card-link.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/use-entity-card-link.ts)