@plugdash/autobuild

autobuild

320 words·3min read

What it does

On every content publish and delete, POSTs (or GETs) a deploy hook URL - typically a Cloudflare Pages, Netlify, or Vercel build webhook. Debounces rapid publishes so a batch of edits triggers one deploy, not ten. No UI, no companion component.

This is the plugin that makes plugdash.dev's core promise real - the admin becomes the thing that moves the site.

Install

npm install @plugdash/autobuild

Register

Open astro.config.mjs at the root of your Astro project. Import the plugin at the top, then add it to the plugins array of the emdash() integration - the one that sits inside Astro's top-level integrations array:

// astro.config.mjs
import { defineConfig } from "astro/config"
import emdash from "emdash/astro"
import { autobuildPlugin } from "@plugdash/autobuild"

export default defineConfig({
  integrations: [
    emdash({
      plugins: [
        autobuildPlugin({
          hookUrl: import.meta.env.CF_PAGES_DEPLOY_HOOK,
          allowedHosts: ["api.cloudflare.com"],
        }),
      ],
    }),
  ],
})

Get the hook URL from your Cloudflare Pages project under Settings -> Builds & deployments -> Deploy hooks. Store it as CF_PAGES_DEPLOY_HOOK in the Pages dashboard environment variables (mark it encrypted).

How it fires

publish in admin -> hook fires -> deploy kicks off -> live

No component

autobuild has no companion component. It is pure infrastructure.

Props

proptypedefaultdescription
method"POST" | "GET""POST"HTTP method for the hook
collectionsstring[]Which collections trigger rebuilds
statusesstring[]["published"]Trigger only on these statuses
debounceMsnumber5000Debounce window for rapid publishes
bodystring | objectOptional request body
headersobjectOptional extra headers

For agents

After install, the env var CF_PAGES_DEPLOY_HOOK must be set for the plugin to do anything. Gate registration on the env var being present - when it is missing, skip the plugin entirely. Verify by publishing a content edit in the admin and confirming a new build starts within the debounceMs window (default 5 seconds).

built with plugdash