Nuxt
Install
npx nuxt module add nuxt-precog
yarn dlx nuxt module add nuxt-precog
pnpm dlx nuxt module add nuxt-precog
bunx nuxt module add nuxt-precog
deno run -A npm:nuxt module add nuxt-precog
TYPESAFE_API_KEY="your-api-key"
Using a Vercel AI Gateway key instead? Name it
AI_GATEWAY_API_KEY and the module routes through the gateway on its own. The two are not
interchangeable; see the API key.
That is the whole setup. The defaults prefetch at most three links and never prerender. Run
nuxt dev, open a page and press Shift+P.
Let it prerender as well
export default defineNuxtConfig({
modules: ["nuxt-precog"],
precog: {
mode: "auto",
takeOverNuxtLinkPrefetch: true,
},
});
takeOverNuxtLinkPrefetch turns off NuxtLink's viewport prefetch and leaves prefetch on
interaction alone, so precog decides ahead of the cursor and Nuxt still covers the moment it
lands.
onMounted fetches run, media can
autoplay. Read prerendering has side effects
first.What it warms
preloadPayload and preloadRouteComponents for the routes the model picked. The payload is
the part that matters, and it only exists for prerendered routes with
experimental.payloadExtraction.
DevTools
A tab with live metrics, the current plan, the ranking with reasons, and buttons that pause, resume and re-predict in the page. Development only.
Coming from 0.2.0
Nothing to do beyond upgrading. The package keeps its name, its options and its behaviour; the workspace split happened underneath it.