Azure Static Web Apps
Azure Static Web Apps provides hosting for static sites with a built-in CI/CD pipeline via GitHub Actions or Azure DevOps. pageflare integrates as a post-build step in your workflow.
How It Works
Section titled “How It Works”Azure Static Web Apps uses a GitHub Actions workflow (or Azure DevOps pipeline) to build and deploy your site. Add pageflare between the build step and the Azure deploy action.
Step 1 — Add Your License
Section titled “Step 1 — Add Your License”- Go to your Static Web App in the Azure Portal.
- Navigate to Configuration > Application settings.
- Add a setting named
PAGEFLARE_LICENSEwith your license key. - Save.
For the build pipeline, add it as a GitHub Actions secret:
- Go to your repository Settings > Secrets and variables > Actions.
- Add a secret named
PAGEFLARE_LICENSE.
Step 2 — Configure the Workflow
Section titled “Step 2 — Configure the Workflow”Azure generates a GitHub Actions workflow when you create a Static Web App. Modify it to include pageflare:
name: Azure Static Web Apps
on: push: branches: [main] pull_request: branches: [main]
jobs: build_and_deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '22'
- name: Install dependencies run: npm ci
- name: Build run: npm run build
- name: Optimize with pageflare uses: getappz/pageflare-cli@v1 with: args: "dist/ --in-place" env: PAGEFLARE_LICENSE: ${{ secrets.PAGEFLARE_LICENSE }}
- name: Deploy uses: Azure/static-web-apps-deploy@v1 with: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} action: upload app_location: dist skip_app_build: trueKey changes from the default workflow:
- Build the site yourself (
npm run build) instead of letting the Azure action build it. - Set
skip_app_build: trueso the Azure action only uploads, not rebuilds. - Add the pageflare step between build and deploy.
Replace dist/ with your framework’s output directory.
Framework Examples
Section titled “Framework Examples” - name: Build run: npm run build
- name: Optimize with pageflare uses: getappz/pageflare-cli@v1 with: args: "dist/ --in-place"
- name: Deploy uses: Azure/static-web-apps-deploy@v1 with: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} action: upload app_location: dist skip_app_build: trueNext.js Static Export
Section titled “Next.js Static Export” - name: Build run: npm run build
- name: Optimize with pageflare uses: getappz/pageflare-cli@v1 with: args: "out/ --in-place"
- name: Deploy uses: Azure/static-web-apps-deploy@v1 with: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} action: upload app_location: out skip_app_build: trueAzure DevOps Pipeline
Section titled “Azure DevOps Pipeline”If you use Azure DevOps instead of GitHub Actions:
trigger: branches: include: - main
pool: vmImage: 'ubuntu-latest'
steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: npm ci && npm run build displayName: 'Build'
- script: | curl -fsSL https://get.appz.dev/pageflare/install.sh | sh ~/.pageflare/bin/pageflare dist/ --in-place --no-progress displayName: 'Optimize with pageflare' env: PAGEFLARE_LICENSE: $(PAGEFLARE_LICENSE)
- task: AzureStaticWebApp@0 inputs: app_location: dist skip_app_build: true env: azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN)Environment Variable Reference
Section titled “Environment Variable Reference”| Variable | Description |
|---|---|
PAGEFLARE_LICENSE | Pro license key. Set in Azure Portal or as a pipeline secret. |
Verify the Deployment
Section titled “Verify the Deployment”Check the GitHub Actions (or Azure DevOps) build logs. 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”Azure action rebuilds the site
Set skip_app_build: true in the Azure deploy action. Without this flag, Azure will rebuild the site using its own Oryx build system, ignoring your pageflare-optimized output.
pageflare output overwritten
Make sure the pageflare step runs after the build and before the Azure deploy action. The deploy action uploads whatever is in app_location.
Custom domain HTTPS issues Azure Static Web Apps handles SSL automatically for custom domains. pageflare does not affect HTTPS — if you see certificate errors, check your Azure DNS configuration.