Skip to content

Astro

Astro is a static site generator with built-in support for React, Vue, Svelte, and other UI frameworks. The pageflare/astro integration hooks into Astro’s build lifecycle and optimizes all output after page generation completes.

Terminal window
npm install -D pageflare

Add the integration to your Astro config:

astro.config.mjs
import { defineConfig } from 'astro/config'
import pageflare from 'pageflare/astro'
export default defineConfig({
integrations: [pageflare()]
})

Every astro build now runs pageflare on the output.

astro.config.mjs
import { defineConfig } from 'astro/config'
import pageflare from 'pageflare/astro'
export default defineConfig({
integrations: [
pageflare({
platform: 'netlify',
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 integration uses Astro’s astro:build:done hook, which fires after all pages have been generated and all assets have been copied to the output directory. This ensures pageflare processes the final, complete output — including static HTML pages, CSS bundles, and processed images.

The output directory is provided by Astro (defaults to dist/).

Astro uses Vite internally, so the pageflare/vite plugin would also work. However, the Astro integration is preferred because:

  • astro:build:done fires after Astro’s own post-processing (SSG page generation, asset pipeline), while Vite’s closeBundle may fire before Astro finishes.
  • The integration receives the output directory directly from Astro, avoiding path resolution issues.

If you’re using Starlight (Astro’s documentation theme), the integration works the same way — add it to your astro.config.mjs alongside the Starlight integration:

astro.config.mjs
import { defineConfig } from 'astro/config'
import starlight from '@astrojs/starlight'
import pageflare from 'pageflare/astro'
export default defineConfig({
integrations: [
starlight({ title: 'My Docs' }),
pageflare()
]
})

pageflare replaces several Astro integrations and Vite plugins. After adding pageflare/astro, you can remove:

Packagepageflare equivalent
astro-compress / @playform/compressHTML, CSS, JS, SVG, and image minification
astro-imagetoolsImage optimization, responsive srcset, lazy loading
@astrojs/sitemapSitemap generation via llm.sitemap config
astro-critters / crittersCritical CSS extraction (Pro)
astro-prefetchSpeculation rules and preconnect hints

The integration 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 npm run build

Integration doesn’t run Make sure you’re running astro build, not astro dev. The integration only runs during production builds.

pageflare processes 0 files If the output directory is empty, check that your Astro config has output: 'static' (the default). Server-rendered (output: 'server') or hybrid modes generate server code, not static HTML.

Build takes too long For large sites (1000+ pages), pageflare may add noticeable build time. Use log: 'info' to see the per-phase timing breakdown. Adding --force skips incremental caching and can be faster for CI builds that always start clean.