Nuxt

nuxt-precog is a Nuxt module. Add it, set a key, and press Shift+P.

Install

npx nuxt module add nuxt-precog
.env
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

nuxt.config.ts
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.

A prerendered page runs its JavaScript: analytics fire, 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.