TYPESCRIPT · ASTRO & UX
GitHub ↗
astro-prefetch-ai-brief — Predictive Hover Link Previews & Summaries for Astro
astro-prefetch-ai-brief enhances internal link prefetching in Astro by displaying a concise 15-word summary tooltip when a reader hovers over a link. It combines Astro's native prefetch router with Chrome's on-device Summarizer API and falls back to pre-compiled meta descriptions.
$ npm install astro-prefetch-ai-brief
01. Architectural Specifications
STATUS: PRODUCTION READY
[ 01 // CAPABILITY ]
Hover Intelligence
Background fetches linked routes on mouseenter/focus and parses content to summarize destination before navigation.
[ 02 // CAPABILITY ]
On-Device Summarizer
Employs window.ai.summarizer for zero-latency, zero-cost AI summaries with no external API keys.
[ 03 // CAPABILITY ]
Built-In LRU Cache
Caches generated briefs in client memory to guarantee instantaneous display on repeated hovers.
02. Implementation & Usage
BUN / ASTRO 5+
// Installation
CLI
bun add astro-prefetch-ai-brief
# or
pnpm add astro-prefetch-ai-brief
// Configuration
astro.config.mjs
// astro.config.mjs
import { defineConfig } from "astro/config";
import prefetchAiBrief from "astro-prefetch-ai-brief";
export default defineConfig({
integrations: [
prefetchAiBrief({
wordCount: 15,
contentSelector: "main, article",
hoverDelayMs: 150,
cacheSize: 50
})
]
});
// Chrome Built-in AI Prerequisites
- 1. Open
chrome://flagsin Google Chrome 128+ - 2. Set
#prompt-api-for-gemini-nanoto Enabled - 3. Set
#optimization-guide-on-device-modelto Enabled ByPassPerfRequirement - 4. Restart Chrome and verify model status at
chrome://components