Skip to content

Heroku

Heroku runs your package.json build script during deployment. pageflare integrates by adding a post-build optimization step to your build command.

Heroku’s Node.js buildpack runs npm run build during deployment. Add pageflare to that script so it optimizes your site’s output before Heroku serves it.

Terminal window
npm install -D @pageflare/cli

Update the build script in your package.json:

package.json
{
"scripts": {
"build": "astro build && npx @pageflare/cli dist/ --in-place --no-progress",
"start": "npx serve dist/"
}
}

Alternatively, use Heroku’s static buildpack. Create a static.json:

static.json
{
"root": "dist/"
}

Set the environment variable via the Heroku CLI or dashboard:

Terminal window
heroku config:set PAGEFLARE_LICENSE=your-license-key

Or in the Heroku dashboard: Settings > Config Vars.

After deploying, check the build logs in the Heroku dashboard or CLI:

Terminal window
heroku logs --tail

Look for the pageflare summary:

Done 145.2 KB saved (38.1%) 1.2s
Files 42 total, 38 optimized, 4 unchanged, 0 errors
FrameworkOutput directory
Astrodist/
Next.js static exportout/
Hugopublic/
Vitedist/
Eleventy_site/

pageflare not found during build Heroku prunes devDependencies by default. Either move @pageflare/cli to dependencies, or set NPM_CONFIG_PRODUCTION=false in your config vars.

pageflare processes 0 files The output directory in your build script doesn’t match where your framework writes output. Check the table above.