Skip to content

Surge

Surge is a simple CLI for publishing static sites. pageflare runs locally (or in CI) after your build and before surge deploys the output.

Build your site, run pageflare to optimize the output directory, then deploy with surge.

Terminal window
npm install -D @pageflare/cli

Add a deploy script to your package.json:

package.json
{
"scripts": {
"build": "astro build",
"optimize": "npx @pageflare/cli dist/ --in-place --no-progress",
"deploy": "npm run build && npm run optimize && surge dist/ my-site.surge.sh"
}
}

Or run the commands manually:

Terminal window
npm run build
npx @pageflare/cli dist/ --in-place --no-progress
surge dist/ my-site.surge.sh
.github/workflows/deploy.yml
name: Deploy to Surge
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build site
run: npm ci && npm run build
- name: Optimize with pageflare
uses: getappz/pageflare-cli@v1
with:
args: "dist/ --in-place"
- name: Deploy to Surge
run: npx surge dist/ my-site.surge.sh --token ${{ secrets.SURGE_TOKEN }}

Set PAGEFLARE_LICENSE as an environment variable locally or as a CI secret:

Terminal window
export PAGEFLARE_LICENSE=your-license-key

After running pageflare, check the terminal output:

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/

Surge deploys unoptimized files Make sure pageflare runs before surge. The --in-place flag overwrites the files in the output directory so Surge deploys the optimized versions.