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.
Install
Section titled “Install”npm install -D pageflareConfiguration
Section titled “Configuration”Add the module to your Nuxt config:
export default defineNuxtConfig({ modules: ['pageflare/nuxt']})Every nuxt generate or nuxt build now runs pageflare on the static output.
Options
Section titled “Options”Configure options directly in nuxt.config.ts using the pageflare key:
export default defineNuxtConfig({ modules: ['pageflare/nuxt'], pageflare: { platform: 'vercel', log: 'info', args: ['--force'], }})| Option | Type | Default | Description |
|---|---|---|---|
platform | string | 'auto' | Deployment platform: auto, vercel, netlify, cloudflare-pages, none |
log | string | 'warn' | Log level: off, error, warn, info, debug |
args | string[] | [] | Extra CLI flags passed to pageflare optimize |
How It Works
Section titled “How It Works”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.
Static Generation vs Server Rendering
Section titled “Static Generation vs Server Rendering”pageflare optimizes static files. The module works best with:
nuxt generate— full static site generation. All pages are prerendered and optimized.nuxt buildwithssr: 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:
export default defineNuxtConfig({ modules: ['pageflare/nuxt'], nitro: { prerender: { routes: ['/'], crawlLinks: true } }})Replacing modules
Section titled “Replacing modules”pageflare replaces several Nuxt modules. After adding pageflare/nuxt, you can remove:
| Package | pageflare equivalent |
|---|---|
nuxt-delay-hydration | Script deferral and lazy loading |
@nuxtjs/critters | Critical CSS extraction (Pro) |
@nuxtjs/fontaine | Font display swap and fallback optimization |
nuxt-simple-sitemap | Sitemap generation via llm.sitemap config |
@nuxt/image | Keep if using server-side image optimization; pageflare handles static output images |
Deploying
Section titled “Deploying”The module works with any deployment target. For platform-specific image optimization:
- Vercel — automatic Vercel Image Optimization
- Netlify — automatic Netlify Image CDN
- Cloudflare Pages — Cloudflare Image Resizing
Pro License
Section titled “Pro License”Set the PAGEFLARE_LICENSE environment variable to unlock Pro optimizations:
PAGEFLARE_LICENSE=your-key nuxt generateTroubleshooting
Section titled “Troubleshooting”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).