AWS Amplify
AWS Amplify Hosting provides a fully managed CI/CD pipeline for static and server-rendered apps. pageflare slots in as a post-build step in your amplify.yml build configuration.
How It Works
Section titled “How It Works”Amplify runs a configurable build pipeline defined in amplify.yml. Add pageflare as a post-build command that optimizes the output before Amplify deploys it.
Step 1 — Add Your License
Section titled “Step 1 — Add Your License”- Go to your app in the Amplify console.
- Navigate to Hosting > Environment variables.
- Add a variable named
PAGEFLARE_LICENSEwith your license key. - Save.
Step 2 — Configure amplify.yml
Section titled “Step 2 — Configure amplify.yml”Add pageflare installation and optimization to your build spec:
version: 1frontend: phases: preBuild: commands: - npm ci build: commands: - npm run build postBuild: commands: - curl -fsSL https://get.appz.dev/pageflare/install.sh | sh - ~/.pageflare/bin/pageflare dist/ --in-place --no-progress artifacts: baseDirectory: dist files: - '**/*' cache: paths: - node_modules/**/* - .pageflare/**/*Replace dist/ with your framework’s output directory.
Using npm instead of curl
Section titled “Using npm instead of curl”If you prefer installing via npm:
version: 1frontend: phases: preBuild: commands: - npm ci build: commands: - npm run build postBuild: commands: - npx pageflare dist/ --in-place --no-progress artifacts: baseDirectory: dist files: - '**/*'This requires @pageflare/cli as a dev dependency in your package.json.
Step 3 — Cache the Binary
Section titled “Step 3 — Cache the Binary”Add .pageflare/**/* to the cache.paths in amplify.yml to avoid re-downloading the binary on every build:
cache: paths: - node_modules/**/* - .pageflare/**/*Framework Examples
Section titled “Framework Examples”version: 1frontend: phases: preBuild: commands: - npm ci build: commands: - npm run build postBuild: commands: - npx pageflare dist/ --in-place --no-progress artifacts: baseDirectory: dist files: - '**/*'Next.js Static Export
Section titled “Next.js Static Export”version: 1frontend: phases: preBuild: commands: - npm ci build: commands: - npm run build postBuild: commands: - npx pageflare out/ --in-place --no-progress artifacts: baseDirectory: out files: - '**/*'version: 1frontend: phases: build: commands: - hugo postBuild: commands: - curl -fsSL https://get.appz.dev/pageflare/install.sh | sh - ~/.pageflare/bin/pageflare public/ --in-place --no-progress artifacts: baseDirectory: public files: - '**/*'Environment Variable Reference
Section titled “Environment Variable Reference”| Variable | Description |
|---|---|
PAGEFLARE_LICENSE | Pro license key. Set in Amplify console. |
Verify the Build
Section titled “Verify the Build”After deploying, check the Build logs in the Amplify console. Expand the postBuild phase and look for the pageflare summary:
Done 145.2 KB saved (38.1%) 1.2s Files 42 total, 38 optimized, 4 unchanged, 0 errorsTroubleshooting
Section titled “Troubleshooting”pageflare command not found
Make sure the install command runs before the optimize command in postBuild. If using npm, ensure @pageflare/cli is in devDependencies and npm ci ran in preBuild.
Binary not cached between builds
Add .pageflare/**/* to cache.paths. Amplify caches these paths between builds so the binary doesn’t need to be downloaded every time.
Build timeout
Amplify has a default build timeout of 30 minutes. For very large sites, pageflare optimization should complete well within this limit. If builds are slow, run with --log info to identify the bottleneck.