Skip to content

Nuxt

Nuxt is a full-stack Vue framework with built-in SSR, SSG, and hybrid rendering. The pageflare/nuxt module integrates directly into Nuxt’s build system and optimizes static output after the build completes.

Terminal window
npm install -D pageflare

Add the module to your Nuxt config:

nuxt.config.ts
export default defineNuxtConfig({
modules: ['pageflare/nuxt']
})

Every nuxt generate or nuxt build now runs pageflare on the static output.

Configure options directly in nuxt.config.ts using the pageflare key:

nuxt.config.ts
export default defineNuxtConfig({
modules: ['pageflare/nuxt'],
pageflare: {
platform: 'vercel',
log: 'info',
args: ['--force'],
}
})
OptionTypeDefaultDescription
platformstring'auto'Deployment platform: auto, vercel, netlify, cloudflare-pages, none
logstring'warn'Log level: off, error, warn, info, debug
argsstring[][]Extra CLI flags passed to pageflare optimize

The module hooks into Nitro’s build lifecycle via the close event, which fires after all static pages have been prerendered and all assets have been written to disk. This ensures pageflare processes the complete output — including prerendered HTML, CSS, JS, and images.

The output directory is read from Nitro’s configuration automatically.

pageflare optimizes static files. The module works best with:

  • nuxt generate — full static site generation. All pages are prerendered and optimized.
  • nuxt build with ssr: true — the public assets directory is optimized, but server-rendered pages are not (they’re generated at request time).

For best results with pageflare, use static generation:

nuxt.config.ts
export default defineNuxtConfig({
modules: ['pageflare/nuxt'],
nitro: {
prerender: {
routes: ['/'],
crawlLinks: true
}
}
})

pageflare replaces several Nuxt modules. After adding pageflare/nuxt, you can remove:

Packagepageflare equivalent
nuxt-delay-hydrationScript deferral and lazy loading
@nuxtjs/crittersCritical CSS extraction (Pro)
@nuxtjs/fontaineFont display swap and fallback optimization
nuxt-simple-sitemapSitemap generation via llm.sitemap config
@nuxt/imageKeep if using server-side image optimization; pageflare handles static output images

The module works with any deployment target. For platform-specific image optimization:

Set the PAGEFLARE_LICENSE environment variable to unlock Pro optimizations:

Terminal window
PAGEFLARE_LICENSE=your-key nuxt generate

Module doesn’t run Make sure the module is listed in modules (not buildModules, which was removed in Nuxt 3). Check that you’re running nuxt generate or nuxt build, not nuxt dev.

pageflare processes 0 files If no static files are generated, ensure you have prerendered routes configured. Nuxt only generates static HTML for routes listed in nitro.prerender.routes or discovered via crawlLinks.

Type errors in nuxt.config.ts The pageflare config key is registered automatically by the module. If your editor shows type errors, restart the Nuxt dev server to regenerate type declarations (nuxt prepare).