Open app

Deploy Hooks

Automatically rebuild your static site when theStacc publishes new content.

Deploy hooks let your static site rebuild automatically whenever theStacc publishes, updates, or unpublishes a blog post. Without deploy hooks, you'd need to manually trigger a rebuild every time content changes.

How deploy hooks work

1. You publish a blog in theStacc
2. theStacc sends a POST request to your deploy hook URL
3. Your hosting platform receives the request and starts a new build
4. During the build, your site fetches the latest content from the Public Blog API
5. New static HTML pages are generated and deployed

The entire process takes 1-3 minutes depending on your site's build time.

Events that trigger a rebuild

theStacc fires a deploy hook when:

  • A new blog is published
  • A published blog is updated (content edited, then synced)
  • A published blog is unpublished (removed from your site)

Draft changes, generation, or approval steps do not trigger a rebuild.

Setting up deploy hooks

Step 1: Get your deploy hook URL

#### Cloudflare Pages

  1. Go to your project in the Cloudflare dashboard
  2. Navigate to Settings > Builds & deployments > Deploy hooks
  3. Click Add deploy hook
  4. Name it "theStacc" and select your production branch
  5. Copy the generated URL (looks like https://api.cloudflare.com/client/v4/pages/webhooks/deploy_hooks/...)

#### Vercel

  1. Go to your project in the Vercel dashboard
  2. Navigate to Settings > Git > Deploy Hooks
  3. Create a hook named "theStacc" for your main branch
  4. Copy the generated URL (looks like https://api.vercel.com/v1/integrations/deploy/...)

#### Netlify

  1. Go to your site in the Netlify dashboard
  2. Navigate to Site configuration > Build & deploy > Build hooks
  3. Click Add build hook
  4. Name it "theStacc" and select your production branch
  5. Copy the generated URL (looks like https://api.netlify.com/build_hooks/...)

#### GitHub Pages

GitHub Pages doesn't have built-in deploy hooks. Use a GitHub Actions workflow instead:

  1. Create a repository dispatch workflow in .github/workflows/rebuild.yml:
name: Rebuild site
on:
  repository_dispatch:
    types: [thestacc-publish]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build and deploy
        run: |
          npm install
          npm run build
  1. Use a webhook-to-dispatch service, or set up a simple Cloudflare Worker that converts the theStacc webhook into a GitHub repository dispatch event.

Step 2: Add the URL to theStacc

  1. Go to Settings > Publishing > API Access in your theStacc dashboard
  2. Find the Deploy Hook section
  3. Paste your deploy hook URL
  4. Click Test to verify the connection — this triggers a test build on your hosting platform
  5. Save

Build optimization

Each deploy hook triggers a full site rebuild. Keep builds fast:

  • Cache API responses — If your framework supports build caching, the theStacc API returns Cache-Control and ETag headers
  • Incremental builds — Frameworks like Next.js and Astro support incremental static regeneration. Only new or changed pages get rebuilt
  • Limit unnecessary rebuilds — theStacc only triggers hooks for published content changes, not drafts or internal edits

Monitoring builds

After setting up deploy hooks:

  1. Publish a test blog in theStacc
  2. Check your hosting platform's build logs — you should see a new build triggered within seconds
  3. Once the build completes, verify the new blog appears on your site
  4. Check the published URL in your browser and confirm content renders correctly

If the build doesn't trigger, verify:

  • The deploy hook URL is correct and active
  • Your hosting platform hasn't disabled automatic builds
  • Your API key is configured in the hosting platform's environment variables

Debouncing

If you publish multiple blogs at once (e.g., approving a batch), theStacc waits 30 seconds after the last publish event before firing the deploy hook. This prevents multiple redundant builds and keeps your hosting platform's build queue clean.

Security

Deploy hook URLs are stored securely and never exposed in the frontend. The URLs themselves act as authentication — anyone with the URL can trigger a build. If you suspect your URL has been compromised:

  1. Delete the current hook on your hosting platform
  2. Create a new one
  3. Update the URL in theStacc settings

Next steps