Webhooks
Rebuild on publish
Start a new build of a prerendered site when an editor publishes.
A prerendered site shows content from its last build. A webhook to the deploy hook of your host starts a new build after each change:
tenon.config.ts
webhooks: {
rebuild: { url: process.env.DEPLOY_HOOK_URL!, debounce: 60 },
},
debounceturns a burst of changes into one build. See Collect changes.- The host needs a running clock. On Vercel, set up the clock route.
- Editors see drafts only on a page that renders per request. See Prerendered pages and preview routes.
Add a deploy button
Some teams publish several changes, then deploy once. An action adds a Deploy button to the admin. The hook URL stays on the server:
tenon.config.ts
admin: {
actions: {
deploy: {
label: "Deploy",
nav: { icon: "rocket" },
confirm: "Rebuild and publish the live site?",
run: async () => {
const response = await fetch(process.env.DEPLOY_HOOK_URL!, { method: "POST" });
if (!response.ok) throw new Error(`The deploy hook answered ${response.status}`);
return "Deploy started";
},
},
},
},
The action calls the hook at once. It does not wait for the clock.
Related resources
- Webhooks: events and delivery.
- Headless: a static frontend on another site.
- Live preview: show drafts before the next build.